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

fix: do not set boolean flags if not defined in argv #119

Merged
merged 1 commit into from
Apr 4, 2018

Commits on Apr 1, 2018

  1. fix: do not set boolean flags if not defined in argv

    BREAKING CHANGE: `boolean` flags defined without a `default` value will now behave like other option type and won't be set in the parsed results when the user doesn't set the corresponding CLI arg.
    
    Previous behavior:
    ```js
    var parse = require('yargs-parser');
    
    parse('--flag', {boolean: ['flag']});
    // => { _: [], flag: true }
    
    parse('--no-flag', {boolean: ['flag']});
    // => { _: [], flag: false }
    
    parse('', {boolean: ['flag']});
    // => { _: [], flag: false }
    ```
    
    New behavior:
    ```js
    var parse = require('yargs-parser');
    
    parse('--flag', {boolean: ['flag']});
    // => { _: [], flag: true }
    
    parse('--no-flag', {boolean: ['flag']});
    // => { _: [], flag: false }
    
    parse('', {boolean: ['flag']});
    // => { _: [] } => flag not set similarly to other option type
    ```
    pvdlg committed Apr 1, 2018
    Configuration menu
    Copy the full SHA
    9f185f2 View commit details
    Browse the repository at this point in the history