Skip to content

Commit

Permalink
fix(docs): update boolean description and examples in docs (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba authored and bcoe committed Nov 9, 2019
1 parent c10c38c commit afd5b48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 1 addition & 5 deletions docs/api.md
Expand Up @@ -74,11 +74,7 @@ For example: `--foo foo bar -- val` will be parsed as
<a name="boolean"></a>.boolean(key)
-------------

Interpret `key` as a boolean. If a non-flag option follows `key` in
`process.argv`, that string won't get set as the value of `key`.

`key` will default to `false`, unless a `default(key, undefined)` is
explicitly set.
Interpret `key` as a boolean. If a non-flag option - unless `true` or `false` - follows `key` in `process.argv`, that string won't get set as the value of `key`.

`key` can be set false explicitly using the `--no-` prefix, [more](/docs/tricks.md#negate).

Expand Down
10 changes: 5 additions & 5 deletions docs/examples.md
Expand Up @@ -233,17 +233,17 @@ boolean_single.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.boolean('v')
.boolean(['r','v'])
.argv
;
console.dir(argv.v);
console.dir([ argv.r, argv.v ]);
console.dir(argv._);
````

***

$ ./boolean_single.js -v "me hearties" yo ho
true
$ ./boolean_single.js -r false -v "me hearties" yo ho
[ false, true ]
[ 'me hearties', 'yo', 'ho' ]


Expand All @@ -262,7 +262,7 @@ console.dir(argv._);
***

$ ./boolean_double.js -x -z one two three
[ true, false, true ]
[ true, undefined, true ]
[ 'one', 'two', 'three' ]

Yargs is here to help you...
Expand Down
4 changes: 2 additions & 2 deletions example/boolean_single.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var argv = require('yargs')
.boolean('v')
.boolean(['r','v'])
.argv
;
console.dir(argv.v);
console.dir([ argv.r, argv.v ]);
console.dir(argv._);

0 comments on commit afd5b48

Please sign in to comment.