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
+10
-5
@@ -37,7 +37,7 @@ import javax.swing.UIManager;
|
||||
public class Main {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Main.class.getName());
|
||||
|
||||
/**
|
||||
/**
|
||||
* Main entry point to the simulator. Creates a simulator and shows the main
|
||||
* window.
|
||||
*
|
||||
@@ -49,6 +49,7 @@ public class Main {
|
||||
|
||||
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("c", "cpu", true, "Specify CPU type."));
|
||||
options.addOption(new Option("r", "rom", true, "Specify ROM file."));
|
||||
@@ -62,6 +63,12 @@ public class Main {
|
||||
String romFile = null;
|
||||
boolean haltOnBreak = false;
|
||||
|
||||
if (line.hasOption("help")) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp("symon", options, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.hasOption("machine")) {
|
||||
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
|
||||
switch (machine) {
|
||||
@@ -111,8 +118,8 @@ public class Main {
|
||||
|
||||
while (true) {
|
||||
if (machineClass == null) {
|
||||
Object[] possibilities = {"Symon", "Multicomp", "Simple", "BenEater"};
|
||||
String s = (String)JOptionPane.showInputDialog(
|
||||
Object[] possibilities = { "Symon", "Multicomp", "Simple", "BenEater" };
|
||||
String s = (String) JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Please choose the machine type to be emulated:",
|
||||
"Machine selection",
|
||||
@@ -121,7 +128,6 @@ public class Main {
|
||||
possibilities,
|
||||
"Symon");
|
||||
|
||||
|
||||
if (s != null && s.equals("Multicomp")) {
|
||||
machineClass = MulticompMachine.class;
|
||||
} else if (s != null && s.equals("Simple")) {
|
||||
@@ -150,7 +156,6 @@ public class Main {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Simulator.MainCommand cmd = simulator.waitForCommand();
|
||||
|
||||
if (cmd.equals(Simulator.MainCommand.SELECTMACHINE)) {
|
||||
|
||||
Reference in new issue
Block a user