Skip to content

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

@dkern

Description

@dkern

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions