Skip to content

Commit

Permalink
docs: clean up README examples (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored Dec 28, 2021
1 parent f848590 commit b25f385
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ const { parseArgs } = require('util')
```

```js
// default
const argv = ['-f', '--foo=a', '--foo', 'b']
// unconfigured
const argv = ['-f', '--foo=a', '--bar', 'b']
const options = {}
const { flags, values, positionals } = parseArgs(argv, options)
flags // { f: true, foo: true}
values // { f: [undefined], foo: [undefined] }
flags // { f: true, bar: true }
values // { foo: 'a' }
positionals // ['b']
```
```js
// withValue
const argv = ['-f', '--foo=a', '--foo', 'b']
const argv = ['-f', '--foo=a', '--bar', 'b']
const options = {
withValue: ['foo']
withValue: ['bar']
}
const { flags, values, positionals } = parseArgs(argv, options)
flags // { f: true, foo: true}
values // { f: [undefined], foo: ['b'] }
flags // { f: true }
values // { foo: 'a', bar: 'b' }
positionals // []
```
```js
Expand All @@ -124,19 +124,19 @@ const options = {
multiples: ['foo']
}
const { flags, values, positionals } = parseArgs(argv, options)
flags // { f: true, foo: true}
values // { f: [undefined], foo: ['a','b'] }
flags // { f: true }
values // { foo: ['a', 'b'] }
positionals // []
```
```js
// shorts
const argv = ['-f', '--foo=a', '--foo', 'b']
const argv = ['-f', 'b']
const options = {
short: { f: 'foo' }
}
const { flags, values, positionals } = parseArgs(argv, options)
flags // { foo: true}
values // { foo: [undefined] }
flags // { foo: true }
values // {}
positionals // ['b']
```

Expand Down

0 comments on commit b25f385

Please sign in to comment.