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

using default: true together with flag: true effectively disables the option and always produces TRUE. #66

Open
GerHobbelt opened this issue Jun 9, 2015 · 1 comment

Comments

@GerHobbelt
Copy link

nomnom does not cope well with 'flag' options which are set to true by default: there's no way to set these to false instead.

Example option:

    var opts = require('nomnom')
        .options({
            debug: {
                abbr: 't',
                flag: true,
                default: true,    // <-- !!! you **always** get opts.debug === true now
                help: 'Debug mode'
            },
            //...
        }).parse();

In other words: there's no -t- (note trailing minus) or similar way to say on the commandline: set flag option to FALSE (rather than TRUE).

Other systems sometimes support -\<flag_option>+ and -\<flag_option>- i.e. trailing + or - to force a TRUE or FALSE value for flag options.

@GerHobbelt
Copy link
Author

Notes: the long-name phrasing of an option, e.g. --debug, already has this ability by prefixing it with no-: --no-debug.

GerHobbelt added a commit to GerHobbelt/nomnom that referenced this issue Jun 9, 2015
…n the 'full' option regex, but the `--no-option` vs. `--option` doesn't seem to be checked thoroughly yet.
GerHobbelt added a commit to GerHobbelt/nomnom that referenced this issue Jun 9, 2015
…sets that 'flag' option to TRUE or FALSE respectively (similar to `--flag` vs. `--no-flag`); tests have been added to verify correct behaviour.
GerHobbelt added a commit to GerHobbelt/nomnom that referenced this issue Jan 31, 2017
…no-' prefix (work sideways related to harthur#66 as we're observing bugs of the same nature)

- stricter long option regexes

- stricter and more tests for boolean (and non-boolean) flags; do note the non-obvious behaviours tested in test/matching.js::testFlagsAbuse()
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

1 participant