Skip to content

Commit b92b0a9

Browse files
committed
docs: add section on inverting boolean flags
1 parent 20238cf commit b92b0a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,21 @@ argv.flags.someString // => "hello" (string)
263263
argv.flags.someNumber // => [1, 2] (number[])
264264
```
265265

266+
#### Inverting boolean flags
267+
To explicitly set a boolean flag to `false`, pass in the value using the `=` operator:
268+
269+
```sh
270+
$ my-script --some-boolean=false
271+
```
272+
273+
Without `=`, the `false` will be parsed as a separate argument:
274+
275+
```sh
276+
$ my-script --some-boolean false
277+
# argv.flags.someBoolean => true
278+
# argv._ => ['false']
279+
```
280+
266281
#### Custom flag types & validation
267282
Custom flag types can be created to validate flags and narrow types. Simply create a new function that accepts a string and returns the parsed value.
268283

0 commit comments

Comments
 (0)