You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`short` {string} (Optional) A single character alias for an option; When appearing one or more times in `args`; Respects the `multiple` configuration
87
87
*`strict` {Boolean} (Optional) A `Boolean` on wheather or not to throw an error when unknown args are encountered
88
88
* Returns: {Object} An object having properties:
89
-
*`flags` {Object}, having properties and `Boolean` values corresponding to parsed options passed
90
-
*`values` {Object}, have properties and `String` values corresponding to parsed options passed
89
+
*`values` {Object}, key:value for each option found. Value is a string for string options, or `true` for boolean options, or an array (of strings or booleans) for options configured as `multiple:true`.
- Does `--no-foo` coerce to `--foo=false`? For all flags? Only boolean flags?
194
-
- no, it sets `{args:{'no-foo': true}}`
188
+
- Does `--no-foo` coerce to `--foo=false`? For all options? Only boolean options?
189
+
- no, it sets `{values:{'no-foo': true}}`
195
190
- Is `--foo` the same as `--foo=true`? Only for known booleans? Only at the end?
196
-
- no, `--foo` is the same as `--foo=`
191
+
- no, they are not the same. There is no special handling of `true` as a value so it is just another string.
197
192
- Does it read environment variables? Ie, is `FOO=1 cmd` the same as `cmd --foo=1`?
198
193
- no
199
194
- Do unknown arguments raise an error? Are they parsed? Are they treated as positional arguments?
200
195
- no, they are parsed, not treated as positionals
201
-
- Does `--` signal the end of flags/options?
202
-
-**open question**
203
-
- If `--` signals the end, is `--` included as a positional? is `program -- foo` the same as `program foo`? Are both `{positionals:['foo']}`, or is the first one `{positionals:['--', 'foo']}`?
196
+
- Does `--` signal the end of options?
197
+
- yes
198
+
- Is `--` included as a positional?
199
+
- no
200
+
- Is `program -- foo` the same as `program foo`?
201
+
- yes, both store `{positionals:['foo']}`
204
202
- Does the API specify whether a `--` was present/relevant?
205
203
- no
206
204
- Is `-bar` the same as `--bar`?
207
205
- no, `-bar` is a short option or options, with expansion logic that follows the
208
206
[Utility Syntax Guidelines in POSIX.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html). `-bar` expands to `-b`, `-a`, `-r`.
209
207
- Is `---foo` the same as `--foo`?
210
208
- no
211
-
- the first flag would be parsed as`'-foo'`
212
-
- the second flag would be parsed as`'foo'`
209
+
- the first is a long option named`'-foo'`
210
+
- the second is a long option named`'foo'`
213
211
- Is `-` a positional? ie, `bash some-test.sh | tap -`
0 commit comments