Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: support - as an argument value (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath authored May 15, 2020
1 parent 2fefccb commit 73fed83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']
let parsingFlags = true
while (this.argv.length) {
const input = this.argv.shift() as string
if (parsingFlags && input.startsWith('-')) {
if (parsingFlags && input.startsWith('-') && input !== '-') {
// attempt to parse as arg
if (this.input['--'] !== false && input === '--') {
parsingFlags = false
Expand Down
7 changes: 7 additions & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ See more help with --help`)
})
expect(out.argv).to.deep.equal(['--foo'])
})

it('parses - as an arg', () => {
const out = parse(['-'], {
args: [{name: 'myarg'}],
})
expect(out.argv).to.deep.equal(['-'])
})
})

describe('args - no args passed in, with defaults', () => {
Expand Down

0 comments on commit 73fed83

Please sign in to comment.