support for commandline arguments
authorSvjatoslav Agejenko <n0@n0-Aspire-8920.(none)>
Sun, 27 Jan 2013 10:11:46 +0000 (12:11 +0200)
committerSvjatoslav Agejenko <n0@n0-Aspire-8920.(none)>
Sun, 27 Jan 2013 10:11:46 +0000 (12:11 +0200)
src/main/java/eu/svjatoslav/instantlauncher/CommandlineHandler.java [new file with mode: 0755]
src/main/java/eu/svjatoslav/instantlauncher/Main.java

diff --git a/src/main/java/eu/svjatoslav/instantlauncher/CommandlineHandler.java b/src/main/java/eu/svjatoslav/instantlauncher/CommandlineHandler.java
new file mode 100755 (executable)
index 0000000..2b71669
--- /dev/null
@@ -0,0 +1,28 @@
+package eu.svjatoslav.instantlauncher;
+
+import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
+import eu.svjatoslav.commons.commandline.parameterparser.Parser;
+
+public class CommandlineHandler {
+
+    Parameter helpParameter = new Parameter("Show commandline optons help", "-h", "--help");
+    private final Parser parser;
+
+    public CommandlineHandler() {
+
+        parser = new Parser();
+        parser.addParameter(helpParameter);
+
+    }
+
+    public void parseCommandlineArguments(final String[] args) {
+
+        if (!parser.parse(args))
+            return;
+
+        if (helpParameter.isParameterSpecified()) {
+            parser.showHelp();
+            System.exit(0);
+        }
+    }
+}
index aede86b..47f1cba 100755 (executable)
@@ -7,6 +7,10 @@ public class Main {
     public static void main(final String[] args) {
 
         try {
+
+            final CommandlineHandler commandlineHandler = new CommandlineHandler();
+            commandlineHandler.parseCommandlineArguments(args);
+
             final InstantLauncher instantLauncher = new InstantLauncher();
             instantLauncher.run();
         } catch (final Exception e) {