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

feat: store end of flags in -- property #9

Merged
merged 3 commits into from
Jan 28, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
docs: end of flags
  • Loading branch information
privatenumber committed Jan 28, 2022
commit 78ef5b583f82c48faf5ead3d2c43879f3cbbb114
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ $ node ./cli --some-string 'hello' --some-boolean --some-number 3
unknownFlags: {
[flagName: string]: (string | boolean)[]
}
_: string[]
_: string[] & {
'--': string[]
}
}
```

Expand Down Expand Up @@ -195,7 +197,7 @@ This outputs the following:
### Arguments
All argument values are stored in the `_` property.

Everything after `--` will not be parsed and be treated as arguments.
Everything after `--` (end-of-flags) is treated as arguments and will be stored in the `_['--']` property.

```sh
$ node ./cli --boolean value --string "hello world" "another value" -- --string "goodbye world"
Expand All @@ -204,7 +206,16 @@ $ node ./cli --boolean value --string "hello world" "another value" -- --string
This outputs the following:
```json5
{
_: ['value', 'another value', '--string', 'goodbye world']
_: [
'value',
'another value',
'--string',
'goodbye world',
'--': [
'--string',
'goodbye world'
]
]
// ...
}
```
Expand Down