Optional options need to be
kyle-long opened this issue · 5 comments
It appears that when using requireFlags
and laxPlacement
optional options are required to be grouped together still.
#!/usr/bin/env node
var args, help, neodocOptions;
help = `Usage:
test.js -a -b [OPTIONS]
Options:
-a blah blah blah
-b blah blah blah
-c blah blah blah
-d blah blah blah
`;
neodocOptions = {
laxPlacement: true,
requireFlags: true
}
args = require("neodoc").run(help, neodocOptions);
console.log("Success");
Here are some cases I ran against it.
$ ./test.js -c -a -b -d
test.js: unexpected option -d
...
$ ./test.js -c -a -d -b
test.js: expected -b, but got -d
...
$ ./test.js -a -c -b
Success
...
$ ./test.js -d -c -a -b
Success
...
$ ./test.js -a -b -c -d
Success
According to the docs for laxPlacement
it sounds like this should work. Advice?
It's a known, annoying behavior. It's actually caused by [options]
expanding to an optional group of optional flags, in your case it would be: -a -b [-c d]
, which should really be -a -b -c -d
.
I've got a patch lying around, originally written in response to #85 that fixes your issue. Will be published in minutes as 1.4.0.
I've added your testcases to the suite and they all pass now as of version 1.4.0
Wow that was quick. Thanks! Do you plan to publish to npm soon?
Should be published now
Got side tracked. Works great! Thanks so much