felixSchl / neodoc

Beautiful, hand-crafted commandline interfaces for node.js
https://felixschl.github.io/neodoc
MIT License
229 stars 9 forks source link

Flags are strictly optional and don't obey the surrounding grammar #61

Closed robotops closed 8 years ago

robotops commented 8 years ago

Flags are considered to be strictly optional despite the surrounding grammar. For instance, the following example documented on http://docopt.org/ does not enforce the requirement that one of the mutually exclusive flags be provided.

Mutually-exclusive elements can be separated with a pipe "|" as follows:

Usage: my_program go (--up | --down | --left | --right) Use parens "( )" to group elements when one of the mutually exclusive cases is required.

felixSchl commented 8 years ago

I am working on a feature branch feature/required-flags that will introduce an option requireFlags that will cause the desired behaviour. I am open for a discussion wether or not that should be the default behaviour for neodoc. For the time being it is opt-in.

felixSchl commented 8 years ago

The branch is coming along nicely and it had the positive side effect that error messages got more love, since in the context of missing flags, they left a lot to be desired off. For example, instead of saying that a group in it's entirety failed, it will track the reason and print that reason. Further, it makes now a distinction between missing arguments and unmet expectations (got '-a' in place of '-b'). But I digress. I will see to have a npm-tagged prerelease to play with later today.

felixSchl commented 8 years ago

There's a tagged release available if you'd like to give it a go. Any feedback would be very welcome - just do npm i neodoc@required-flags. Please let me know if the behaviour is as you'd expect and if the error messages are sufficiently helpful.

felixSchl commented 8 years ago

@robotops you can try the new behaviour now at https://felixschl.github.io/neodoc (it's running a preview version of v0.8.0. feedback would be much appreciated)

felixSchl commented 8 years ago

This feature has landed with v0.8.0 - ef429aa37eaa51c45485af071aacef618a9fb29f