Skip to content
Snippets Groups Projects
Commit 6dfb4b7a authored by Mick Jordan's avatar Mick Jordan
Browse files

reset RCmdOptions (debugger usage)

parent f352f14c
Branches
No related tags found
No related merge requests found
......@@ -119,6 +119,12 @@ public class RCmdOptions {
return optionList;
}
public static void reset() {
for (Option<?> option : optionList) {
option.reset();
}
}
public static enum OptionType {
BOOLEAN,
STRING,
......@@ -147,9 +153,13 @@ public class RCmdOptions {
* The help text.
*/
public final String help;
/** The default value. */
private final T defaultValue;
/**
* The value, either from the default or set on the command line.
*/
private T value;
/**
* Set {@code true} iff the short form of a {@code OptionType.STRING} option matched.
......@@ -172,6 +182,7 @@ public class RCmdOptions {
this.shortName = shortName == null ? null : shortKey(shortName);
this.name = name == null ? null : key(name);
this.help = help;
this.defaultValue = defaultValue;
this.value = defaultValue;
}
......@@ -225,6 +236,10 @@ public class RCmdOptions {
this.value = (T) new Boolean(value);
}
public void reset() {
this.value = defaultValue;
}
@SuppressWarnings("unchecked")
public void setValue(String value) {
if (type == OptionType.REPEATED_STRING) {
......
......@@ -59,6 +59,7 @@ public class RCmdOptionsParser {
* Parse the arguments, setting the corresponding {@code Option values}.
*/
public static Result parseArguments(Client client, String[] args) {
RCmdOptions.reset();
int i = 0;
int firstNonOptionArgIndex = -1;
while (i < args.length) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment