private static enum Opt
{
BOOLEAN, STRING, UNARY, MULTI, LINKED, NODUPLICATEVALUES, BOOTSTRAP,
- GLOB, NOACTION
+ GLOB, NOACTION, ALLOWSUBSTITUTIONS
}
public enum Arg
SHOWOVERVIEW.setOptions(Opt.UNARY, Opt.LINKED);
ANNOTATIONS.setOptions(Opt.STRING, Opt.LINKED);
COLOUR.setOptions(Opt.STRING, Opt.LINKED);
- FEATURES.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
- GROOVY.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
+ FEATURES.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI,
+ Opt.ALLOWSUBSTITUTIONS);
+ GROOVY.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI,
+ Opt.ALLOWSUBSTITUTIONS);
GROUPS.setOptions(Opt.STRING, Opt.LINKED);
HEADLESS.setOptions(Opt.UNARY, Opt.BOOTSTRAP);
JABAWS.setOptions(Opt.STRING);
- ANNOTATION.setOptions(true, Opt.BOOLEAN);
- ANNOTATION2.setOptions(true, Opt.BOOLEAN);
+ ANNOTATION.setOptions(true, Opt.BOOLEAN, Opt.LINKED);
+ ANNOTATION2.setOptions(true, Opt.BOOLEAN, Opt.LINKED);
DISPLAY.setOptions(true, Opt.BOOLEAN);
GUI.setOptions(true, Opt.BOOLEAN);
NEWS.setOptions(true, Opt.BOOLEAN);
// expects a string value
SORTBYTREE.setOptions(true, Opt.BOOLEAN);
USAGESTATS.setOptions(true, Opt.BOOLEAN);
- OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB);
- OPEN2.setOptions(Opt.STRING, Opt.LINKED);
+ OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB,
+ Opt.ALLOWSUBSTITUTIONS);
+ OPEN2.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
PROPS.setOptions(Opt.STRING, Opt.BOOTSTRAP);
QUESTIONNAIRE.setOptions(Opt.STRING);
SETPROP.setOptions(Opt.STRING);
VDOC.setOptions(Opt.UNARY);
VSESS.setOptions(Opt.UNARY);
- OUTPUT.setOptions(Opt.STRING, Opt.LINKED);
+ OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
OUTPUTTYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
SSANNOTATION.setOptions(Opt.BOOLEAN, Opt.LINKED);
TEMPFAC_DESC.setOptions(Opt.STRING, Opt.LINKED);
TEMPFAC_SHADING.setOptions(Opt.BOOLEAN, Opt.LINKED);
TITLE.setOptions(Opt.STRING, Opt.LINKED);
- PAEMATRIX.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
+ PAEMATRIX.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI,
+ Opt.ALLOWSUBSTITUTIONS);
NOSTRUCTURE.setOptions(Opt.UNARY, Opt.LINKED);
- STRUCTURE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
+ STRUCTURE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI,
+ Opt.ALLOWSUBSTITUTIONS);
WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED);
- IMAGE.setOptions(Opt.STRING, Opt.LINKED);
+ IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
QUIT.setOptions(Opt.UNARY);
CLOSE.setOptions(Opt.UNARY, Opt.LINKED);
DEBUG.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
QUIET.setOptions(Opt.UNARY, Opt.MULTI, Opt.BOOTSTRAP);
- ARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB);
+ ARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB,
+ Opt.ALLOWSUBSTITUTIONS);
INCREMENT.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION);
NPP.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION);
SUBSTITUTIONS.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION);
if (a.hasOption(Opt.GLOB) && vals != null && vals.size() > 0)
{
for (String v : vals)
- avs.addValue(val, argIndex++);
+ {
+ avs.addValue(makeSubstitutions(v), argIndex++);
+ }
}
else
{
- avs.addValue(val, argIndex);
+ avs.addValue(makeSubstitutions(val), argIndex);
}
}
else if (a.hasOption(Opt.BOOLEAN))
}
}
+ private String makeSubstitutions(String val)
+ {
+ if (!this.substitutions)
+ return val;
+
+ String subvals;
+ String rest;
+ if (val.indexOf('[') == 0 && val.indexOf(']') > 1)
+ {
+ int closeBracket = val.indexOf(']');
+ if (val.length() == closeBracket)
+ return val;
+ subvals = val.substring(0, closeBracket + 1);
+ rest = val.substring(closeBracket + 1);
+ }
+ else
+ {
+ subvals = "";
+ rest = val;
+ }
+ rest.replace(AUTOCOUNTERLINKEDID, String.valueOf(idCounter));
+ rest.replace(INCREMENTAUTOCOUNTERLINKEDID, String.valueOf(++idCounter));
+ rest.replace("{}", String.valueOf(defaultLinkedIdCounter));
+
+ return new StringBuilder(subvals).append(rest).toString();
+ }
+
/*
* A helper method to take a list of String args where we're expecting
* {"--previousargs", "--arg", "file1", "file2", "file3", "--otheroptionsornot"}
return;
if (item.indexOf('[') == 0 && item.indexOf(']') > 1)
{
- int openBracket = item.indexOf('[');
+ int openBracket = 0;
int closeBracket = item.indexOf(']');
String subvalsString = item.substring(openBracket + 1,
closeBracket);