From 26a6efe57cd4d5674a4a05c802a85cc0332d32e8 Mon Sep 17 00:00:00 2001 From: Marcel Otte Date: Mon, 29 Dec 2014 16:57:29 +0100 Subject: [PATCH] some comments, and starting to implement regex possibilities. --- .../src/to/mmo/cmdlineoptions/CmdOptions.java | 1 + .../mmo/cmdlineoptions/CommandLineOption.java | 43 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/java/src/to/mmo/cmdlineoptions/CmdOptions.java b/java/src/to/mmo/cmdlineoptions/CmdOptions.java index 7eb12f0..1700bd0 100644 --- a/java/src/to/mmo/cmdlineoptions/CmdOptions.java +++ b/java/src/to/mmo/cmdlineoptions/CmdOptions.java @@ -46,6 +46,7 @@ public class CmdOptions { this.combineSwitches = on; } + @SuppressWarnings("static-access") public void setOptionCharacter(String c) { this.optionChar = c; } diff --git a/java/src/to/mmo/cmdlineoptions/CommandLineOption.java b/java/src/to/mmo/cmdlineoptions/CommandLineOption.java index 8a66f98..317dcb6 100644 --- a/java/src/to/mmo/cmdlineoptions/CommandLineOption.java +++ b/java/src/to/mmo/cmdlineoptions/CommandLineOption.java @@ -4,26 +4,37 @@ import java.util.ArrayList; public class CommandLineOption { private String name; - private ArrayList cmd; - private ArrayList cmdLong; - private String description; - private ArrayList defaultParameter; + private ArrayList cmd; // short command, only 1 character! + private ArrayList cmdLong; // long command, several characters + private String description; // description of the cmd line parameter + private ArrayList examples; // provide examples?! + private ArrayList defaultParameters; // parameter not set but you + // need input? + private ArrayList possibleParams; // 'enum' of options which can be + // specified + private ArrayList values; // the real values given on the command + // line - private ArrayList possibleParams; - private boolean set; - private boolean required; - private ArrayList values; - private int maxParameters, minParameters; - private ArrayList examples; - private int stepSizeParameters; + private ArrayList parameterRegexes; // regex fun, here you can + // specify regex strings for + // multiple parameters + private boolean set; // is it set or not? + private boolean required; // required or not? + private int maxParameters, minParameters; // count of parameters + private int stepSizeParameters; // parameter count has always to be a + // multiple of ... step size parameter! + + // large footprint here ... future optimization: create arrays only when + // needed... public CommandLineOption() { values = new ArrayList(); cmd = new ArrayList(); cmdLong = new ArrayList(); - defaultParameter = new ArrayList(); + defaultParameters = new ArrayList(); possibleParams = new ArrayList(); examples = new ArrayList(); + parameterRegexes = new ArrayList(); } public CommandLineOption(String name) { @@ -36,7 +47,7 @@ public class CommandLineOption { } public ArrayList getDefaultParameter() { - return defaultParameter; + return defaultParameters; } public CommandLineOption addCommand(String cmd) { @@ -59,7 +70,7 @@ public class CommandLineOption { } public CommandLineOption addDefaultParameter(String d) { - this.defaultParameter.add(d); + this.defaultParameters.add(d); return this; } @@ -144,9 +155,9 @@ public class CommandLineOption { + ", "; } ret += ")"; - if (help && defaultParameter.size() > 0) { + if (help && defaultParameters.size() > 0) { ret += ": default="; - for (String s : defaultParameter) { + for (String s : defaultParameters) { ret += s + ","; } }