private int argIndex = 0;
+ private BootstrapArgs bootstrapArgs = null;
+
static
{
argMap = new HashMap<>();
public ArgParser(String[] args)
{
- this(args, false);
+ this(args, false, null);
}
- public ArgParser(String[] args, boolean initsubstitutions)
+ public ArgParser(String[] args, boolean initsubstitutions,
+ BootstrapArgs bsa)
{
// Make a mutable new ArrayList so that shell globbing parser works.
// (When shell file globbing is used, there are a sequence of non-Arg
// consumed by the --append/--argfile/etc Arg which is most easily done by
// removing these filenames from the list one at a time. This can't be done
// with an ArrayList made with only Arrays.asList(String[] args). )
- this(new ArrayList<>(Arrays.asList(args)), initsubstitutions);
+ this(new ArrayList<>(Arrays.asList(args)), initsubstitutions, false,
+ bsa);
}
public ArgParser(List<String> args, boolean initsubstitutions)
{
- this(args, initsubstitutions, false);
+ this(args, initsubstitutions, false, null);
}
public ArgParser(List<String> args, boolean initsubstitutions,
- boolean allowPrivate)
+ boolean allowPrivate, BootstrapArgs bsa)
{
// do nothing if there are no "--" args and (some "-" args || >0 arg is
// "open")
parse(new ArrayList<String>(), false, false);
return;
}
+ if (bsa != null)
+ this.bootstrapArgs = bsa;
+ else
+ this.bootstrapArgs = BootstrapArgs.getBootstrapArgs(args);
parse(args, initsubstitutions, allowPrivate);
}
return vals;
}
+ public BootstrapArgs getBootstrapArgs()
+ {
+ return bootstrapArgs;
+ }
+
public boolean isSet(Arg a)
{
- return a.hasOption(Opt.LINKED) ? isSet("", a) : isSet(null, a);
+ return a.hasOption(Opt.LINKED) ? isSetAtAll(a) : isSet(null, a);
+ }
+
+ public boolean isSetAtAll(Arg a)
+ {
+ for (String linkedId : linkedOrder)
+ {
+ if (isSet(linkedId, a))
+ return true;
+ }
+ return false;
}
public boolean isSet(String linkedId, Arg a)
return avm == null ? false : avm.containsArg(a);
}
- public boolean getBool(Arg a)
+ public boolean getBoolean(Arg a)
{
if (!a.hasOption(Opt.BOOLEAN) && !a.hasOption(Opt.UNARY))
{
}
public static ArgParser parseArgFiles(List<String> argFilenameGlobs,
- boolean initsubstitutions)
+ boolean initsubstitutions, BootstrapArgs bsa)
{
List<File> argFiles = new ArrayList<>();
argFiles.addAll(FileUtils.getFilesFromGlob(pattern));
}
- return parseArgFileList(argFiles, initsubstitutions);
+ return parseArgFileList(argFiles, initsubstitutions, bsa);
}
public static ArgParser parseArgFileList(List<File> argFiles,
- boolean initsubstitutions)
+ boolean initsubstitutions, BootstrapArgs bsa)
{
List<String> argsList = new ArrayList<>();
for (File argFile : argFiles)
}
// Third param "true" uses Opt.PRIVATE args --setargile=argfile and
// --unsetargfile
- return new ArgParser(argsList, initsubstitutions, true);
+ return new ArgParser(argsList, initsubstitutions, true, bsa);
}
protected static List<String> readArgFile(File argFile)