Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Optional options need to be #89

Closed
kyle-long opened this issue Feb 16, 2017 · 5 comments
Closed

Optional options need to be #89

kyle-long opened this issue Feb 16, 2017 · 5 comments

Comments

@kyle-long
Copy link

kyle-long commented Feb 16, 2017

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?

@felixSchl
Copy link
Owner

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.

felixSchl added a commit that referenced this issue Feb 16, 2017
@felixSchl
Copy link
Owner

I've added your testcases to the suite and they all pass now as of version 1.4.0

@kyle-long
Copy link
Author

Wow that was quick. Thanks! Do you plan to publish to npm soon?

@felixSchl
Copy link
Owner

Should be published now

@kyle-long
Copy link
Author

Got side tracked. Works great! Thanks so much

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants