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
Copy file name to clipboardExpand all lines: readme.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,17 @@ Default: `[]`
93
93
94
94
A single key (or array of keys) that should be parsed as `String`s.
95
95
96
+
#### options.unknown
97
+
98
+
Type: `function`<br>
99
+
Default: `undefined`
100
+
101
+
Callback that is run when a parsed flag has not been defined as a known key or alias. Its only parameter is the unknown flag itself; eg `--foobar` or `-f`.
102
+
103
+
Once an unknown flag is encountered, parsing will terminate, regardless of your return value.
104
+
105
+
> **Note:**`mri`_only_ checks for unknown flags if `options.unknown`**and**`options.alias` are populated. Otherwise, everything will be accepted.
106
+
96
107
97
108
## Comparisons
98
109
@@ -109,9 +120,10 @@ A single key (or array of keys) that should be parsed as `String`s.
109
120
mri(['-abc', 'hello']);
110
121
//=> { _:[], a:true, b:true, c:'hello' }
111
122
```
123
+
- The `opts.unknown` behaves differently:
124
+
- Unlike `minimist`, `mri` will not continuecontinue parsing after encountering an unknown flag
112
125
- Missing `options`:
113
126
-`opts.stopEarly`
114
-
-`opts.unknown`
115
127
-`opts['--']`
116
128
- Ignores newlines (`\n`) within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L69-L80))
117
129
- Ignores slashBreaks within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L147-L157))
@@ -135,6 +147,7 @@ A single key (or array of keys) that should be parsed as `String`s.
0 commit comments