Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining boolean options via Command#option() defaults to undefined, not false. #574

Closed
karbica opened this issue Sep 21, 2016 · 4 comments
Labels
docs README (or other docs) could be improved

Comments

@karbica
Copy link

karbica commented Sep 21, 2016

According to the example http://tj.github.io/commander.js/#Command.prototype.option, when defining an option that does not have a required or optional value, it defaults to undefined when it should default to false. However, if it's long hand value contains -no-, it properly defaults to true.

@louisgv
Copy link

louisgv commented Apr 14, 2017

Same issue, the document should be more clear about all flags that contains -no-, as these flags are treated differently. E.g:

  • They are stripped off the no words
  • They are defaulted to true

Confused me a bit when trying to setup a no flag :p

@usmonster
Copy link
Contributor

Tried to clarify this behavior in tests on #795. Please take a look, and feel free to comment!

@shadowspawn
Copy link
Collaborator

I have proposed a large update to options coverages in README in #953

@shadowspawn
Copy link
Collaborator

I have rewritten the options description in the README, mentioning the default boolean value being undefined, and covering negatable boolen separately (both with examples). Hopefully this should make it clearer what the current behaviour is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs README (or other docs) could be improved
Projects
None yet
Development

No branches or pull requests

4 participants