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

Dot-notation boolean flags aren't parsed correctly #617

Closed
lasalvavida opened this issue Sep 2, 2016 · 2 comments · Fixed by yargs/yargs-parser#63
Closed

Dot-notation boolean flags aren't parsed correctly #617

lasalvavida opened this issue Sep 2, 2016 · 2 comments · Fixed by yargs/yargs-parser#63

Comments

@lasalvavida
Copy link

Given the following example:

testScript.js

var argv = require('yargs')
    .options({
        'nested.value': {
            type: 'boolean'
        }
    }).argv;

console.log(argv);

./bin/testScript

{ _: [],
nested: { value: false },
'$0': 'bin\testScript.js' }

./bin/testScript.js --nested.value

{ _: [],
nested: { value: [ false, true ] },
'$0': 'bin\testScript.js' }

The value is placed into an array instead of changing the boolean value.

@nexdrew nexdrew added the bug label Sep 2, 2016
@lasalvavida
Copy link
Author

lasalvavida commented Sep 15, 2016

Did some digging. This was an issue in yargs-parser that is no longer present in master. This can be closed after release.

It would appear that my original assessment was incorrect. This is still a bug in 6.0.0.

var parse = require('yargs-parser');
console.log(parse(
    ['--nested.value'].join(' '),
    {
        boolean : ['nested.value'],
        default : {
            'nested.value' : false
        }
    }
));

{ _: [], nested: { value: [ false, true ] } }

Not specifying that it is a boolean works as a workaround, but this is still a bug.

@babhishek21
Copy link
Contributor

I would like to work on this. Can anyone help me out a bit?

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

Successfully merging a pull request may close this issue.

4 participants