import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
private Set<File> argFiles = new HashSet<>();
+ private Set<Opt> argsOptions = new HashSet<>();
+
+ private Set<Type> argsTypes = new HashSet<>();
+
public static BootstrapArgs getBootstrapArgs(String[] args)
{
List<String> argList = new ArrayList<>(Arrays.asList(args));
}
}
+ // after all other args, look for Opt.PREFIX args if still not found
+ if (!ArgParser.argMap.containsKey(argName))
+ {
+ for (Arg potentialArg : EnumSet.allOf(Arg.class))
+ {
+ if (potentialArg.hasOption(Opt.PREFIXKEV) && argName != null
+ && argName.startsWith(potentialArg.getName())
+ && val != null)
+ {
+ val = argName.substring(potentialArg.getName().length())
+ + ArgParser.EQUALS + val;
+ argName = argName.substring(0,
+ potentialArg.getName().length());
+ break;
+ }
+ }
+ }
+
if (ArgParser.argMap.containsKey(argName) && val == null)
{
val = "true";
Arg a = ArgParser.argMap.get(argName);
+ if (a != null)
+ {
+ for (Opt opt : a.getOptions())
+ {
+ if (!argsOptions.contains(opt))
+ {
+ argsOptions.add(opt);
+ }
+ }
+ Type t = a.getType();
+ if (!argsTypes.contains(t))
+ {
+ argsTypes.add(t);
+ }
+ }
+
if (a == null || !a.hasOption(Opt.BOOTSTRAP))
{
// not a valid bootstrap arg
* Retrieves the first value even if MULTI.
* A convenience for non-MULTI args.
*/
- public String get(Arg a)
+ public String getValue(Arg a)
{
if (!bootstrapArgMap.containsKey(a))
return null;
{
if (!bootstrapArgMap.containsKey(a))
return d;
- return Boolean.parseBoolean(get(a));
+ return Boolean.parseBoolean(getValue(a));
}
public boolean getBoolean(Arg a)
return false;
}
if (bootstrapArgMap.containsKey(a))
- return Boolean.parseBoolean(get(a));
+ {
+ return Boolean.parseBoolean(getValue(a));
+ }
else
+ {
return a.getDefaultBoolValue();
+ }
+ }
+
+ public boolean argsHaveOption(Opt opt)
+ {
+ return argsOptions.contains(opt);
+ }
+
+ public boolean argsHaveType(Type type)
+ {
+ return argsTypes.contains(type);
+ }
+
+ public boolean isHeadless()
+ {
+ boolean isHeadless = false;
+ if (this.argsHaveType(Type.HELP))
+ {
+ // --help, --help-all, ... specified => headless
+ isHeadless = true;
+ }
+ else if (this.contains(Arg.VERSION))
+ {
+ // --version specified => headless
+ isHeadless = true;
+ }
+ else if (this.contains(Arg.GUI))
+ {
+ // --gui specified => forced NOT headless
+ isHeadless = !this.getBoolean(Arg.GUI);
+ }
+ else if (this.contains(Arg.HEADLESS))
+ {
+ // --headless, --noheadless specified => use value
+ isHeadless = this.getBoolean(Arg.HEADLESS);
+ }
+ else if (this.argsHaveOption(Opt.OUTPUTFILE))
+ {
+ // --output file.fa, --image pic.png, --structureimage struct.png =>
+ // assume headless unless above has been already specified
+ isHeadless = true;
+ }
+ return isHeadless;
}
}