From 0d46abdbadb1d25f38408c5ba9958f9a8bf31014 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 27 Jan 2013 12:11:46 +0200 Subject: [PATCH] support for commandline arguments --- .../instantlauncher/CommandlineHandler.java | 28 +++++++++++++++++++ .../eu/svjatoslav/instantlauncher/Main.java | 4 +++ 2 files changed, 32 insertions(+) create mode 100755 src/main/java/eu/svjatoslav/instantlauncher/CommandlineHandler.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 index 0000000..2b71669 --- /dev/null +++ b/src/main/java/eu/svjatoslav/instantlauncher/CommandlineHandler.java @@ -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); + } + } +} diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Main.java b/src/main/java/eu/svjatoslav/instantlauncher/Main.java index aede86b..47f1cba 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Main.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Main.java @@ -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) { -- 2.20.1