Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document handling of -- argument #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,33 @@ console.log(args);
*/
```

### Special `--` argument

There is a special case for the `--` argument, if encountered all subsequent arguments are appended to `arg._` and parsing for the remaining arguments is skipped.
This special behaviour for `--` overrides the argument spec, you cannot trick it into getting parsed.

For example:

```javascript
const args = arg(
{
'--foo': [String],
},
{
argv: ['--foo', '1', '--', '2', '--foo', '3']
}
);
```

results in:

```javascript
const args = {
_: [ '2', '--foo', '3' ],
'--foo': [ '1' ],
};
```

### Options

If a second parameter is specified and is an object, it specifies parsing options to modify the behavior of `arg()`.
Expand Down