Skip to content

Commit 7eb7ec5

Browse files
Qix-rauchg
authored andcommitted
add documentation for stopAtPositional (#36)
1 parent 842dff4 commit 7eb7ec5

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,39 @@ const args = {
217217
}
218218
```
219219

220-
#### Errors
220+
#### `stopAtPositional`
221+
222+
When `stopAtPositional` is set to `true`, `arg` will halt parsing at the first
223+
positional argument.
224+
225+
For example:
226+
227+
```javascript
228+
const arg = require('arg');
229+
230+
const argv = ['--foo', 'hello', '--bar'];
231+
232+
const args = arg(
233+
{
234+
'--foo': Boolean,
235+
'--bar': Boolean
236+
}, {
237+
argv,
238+
stopAtPositional: true
239+
}
240+
);
241+
```
242+
243+
results in:
244+
245+
```javascript
246+
const args = {
247+
_: ['hello', '--bar'],
248+
'--foo': true
249+
};
250+
```
251+
252+
### Errors
221253

222254
Some errors that `arg` throws provide a `.code` property in order to aid in recovering from user error, or to
223255
differentiate between user error and developer error (bug).

0 commit comments

Comments
 (0)