I have the following:
final String scriptName = new File(getClass().protectionDomain.codeSource.location.path).getName()
final cli = new CliBuilder(
stopAtNonOption: false,
usage: "${scriptName} ARGUMENTS",
width: 80)
cli.with {
_ longOpt: "known-option-0", args: 1, argName: "KNOWN_OPTION_0", "Known option."
_ longOpt: "known-option-1", args: 1, argName: "KNOWN_OPTION_1", "Known option."
}
I would like to be able to call it with:
options = cli.parse(['--known-option-0=0', '--unknown-option=aoeu', '--known-option-1=1'])
such that there’s no parsing error, without having to add –unknown-option to the list of accepted options, and such that both known-option-0 and known-option-1 are set.
If I set:
stopAtNonOption: true,
no error is emitted, but:
options.'known-option-0' == 0
options.'known-option-1' == false
How can I get all known options to be parsed and ignore unknown options?
1 Answer