Skip to content

Commit b25f385

Browse files
authored
docs: clean up README examples (#23)
1 parent f848590 commit b25f385

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,23 @@ const { parseArgs } = require('util')
9797
```
9898

9999
```js
100-
// default
101-
const argv = ['-f', '--foo=a', '--foo', 'b']
100+
// unconfigured
101+
const argv = ['-f', '--foo=a', '--bar', 'b']
102102
const options = {}
103103
const { flags, values, positionals } = parseArgs(argv, options)
104-
flags // { f: true, foo: true}
105-
values // { f: [undefined], foo: [undefined] }
104+
flags // { f: true, bar: true }
105+
values // { foo: 'a' }
106106
positionals // ['b']
107107
```
108108
```js
109109
// withValue
110-
const argv = ['-f', '--foo=a', '--foo', 'b']
110+
const argv = ['-f', '--foo=a', '--bar', 'b']
111111
const options = {
112-
withValue: ['foo']
112+
withValue: ['bar']
113113
}
114114
const { flags, values, positionals } = parseArgs(argv, options)
115-
flags // { f: true, foo: true}
116-
values // { f: [undefined], foo: ['b'] }
115+
flags // { f: true }
116+
values // { foo: 'a', bar: 'b' }
117117
positionals // []
118118
```
119119
```js
@@ -124,19 +124,19 @@ const options = {
124124
multiples: ['foo']
125125
}
126126
const { flags, values, positionals } = parseArgs(argv, options)
127-
flags // { f: true, foo: true}
128-
values // { f: [undefined], foo: ['a','b'] }
127+
flags // { f: true }
128+
values // { foo: ['a', 'b'] }
129129
positionals // []
130130
```
131131
```js
132132
// shorts
133-
const argv = ['-f', '--foo=a', '--foo', 'b']
133+
const argv = ['-f', 'b']
134134
const options = {
135135
short: { f: 'foo' }
136136
}
137137
const { flags, values, positionals } = parseArgs(argv, options)
138-
flags // { foo: true}
139-
values // { foo: [undefined] }
138+
flags // { foo: true }
139+
values // {}
140140
positionals // ['b']
141141
```
142142

0 commit comments

Comments
 (0)