Added handling of -h/--help CLI option, to print out available options. (#22)
Small CLI improvement: adding a -h / --help switch, to be able to get a printout of the available options. Reviewed-on: https://codeberg.org/sethm/symon/pulls/22 Reviewed-by: Seth Morabito <sethm@noreply.codeberg.org>
This commit is contained in:
1 parent
995b372f55
commit
2e2163fefb
1 file changed
+7
-2
@@ -49,6 +49,7 @@ public class Main {
|
|||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
|
options.addOption(new Option("h", "help", false, "Print this message."));
|
||||||
options.addOption(new Option("m", "machine", true, "Specify machine type."));
|
options.addOption(new Option("m", "machine", true, "Specify machine type."));
|
||||||
options.addOption(new Option("c", "cpu", true, "Specify CPU type."));
|
options.addOption(new Option("c", "cpu", true, "Specify CPU type."));
|
||||||
options.addOption(new Option("r", "rom", true, "Specify ROM file."));
|
options.addOption(new Option("r", "rom", true, "Specify ROM file."));
|
||||||
@@ -62,6 +63,12 @@ public class Main {
|
|||||||
String romFile = null;
|
String romFile = null;
|
||||||
boolean haltOnBreak = false;
|
boolean haltOnBreak = false;
|
||||||
|
|
||||||
|
if (line.hasOption("help")) {
|
||||||
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
|
formatter.printHelp("symon", options, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.hasOption("machine")) {
|
if (line.hasOption("machine")) {
|
||||||
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
|
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
|
||||||
switch (machine) {
|
switch (machine) {
|
||||||
@@ -121,7 +128,6 @@ public class Main {
|
|||||||
possibilities,
|
possibilities,
|
||||||
"Symon");
|
"Symon");
|
||||||
|
|
||||||
|
|
||||||
if (s != null && s.equals("Multicomp")) {
|
if (s != null && s.equals("Multicomp")) {
|
||||||
machineClass = MulticompMachine.class;
|
machineClass = MulticompMachine.class;
|
||||||
} else if (s != null && s.equals("Simple")) {
|
} else if (s != null && s.equals("Simple")) {
|
||||||
@@ -150,7 +156,6 @@ public class Main {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Simulator.MainCommand cmd = simulator.waitForCommand();
|
Simulator.MainCommand cmd = simulator.waitForCommand();
|
||||||
|
|
||||||
if (cmd.equals(Simulator.MainCommand.SELECTMACHINE)) {
|
if (cmd.equals(Simulator.MainCommand.SELECTMACHINE)) {
|
||||||
|
|||||||
Reference in new issue
Block a user