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

No way to know if parameter is set with --no- options #630

Closed
dkern opened this issue May 10, 2017 · 3 comments
Closed

No way to know if parameter is set with --no- options #630

dkern opened this issue May 10, 2017 · 3 comments

Comments

@dkern
Copy link

dkern commented May 10, 2017

Hello,

I want to use two parameters on a command, somehow like this:

program.option("-d, --debug", "overwrite debug configuration with 'true'")
       .option("-n, --no-debug", "overwrite debug configuration with 'false'");

My program has a configuration file, where a default value for debug is defined. The parameters -d and -n should override this setting, but only when set. If not set the default value should be picked. So for example:

Default value for debug in configuration is true:

command      <-  debug is enabled
command -d   <-  debug is enabled
command -n   <-  debug is disabled

Default value for debug in configuration is false:

command      <-  debug is disabled
command -d   <-  debug is enabled
command -n   <-  debug is disabled

The problem is, when using a --no- parameter, commander always set a default value for debug and there is no way to see, if one of those options was set while execute the command. I would need a way to see if -d or -n was really given by the user.

Otherwise, it will always overwrite my configuration and not only when the user want to do it especially.

@usmonster
Copy link
Contributor

Hey, I may have solved this in #795. Please try it out and let me know?

@shadowspawn
Copy link
Collaborator

Closing in favour of #108

@shadowspawn
Copy link
Collaborator

This issue will be resolved when v3.0.0 is released. Available now as a prerelease. See #1001

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

No branches or pull requests

3 participants