-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: handling quoted strings and options validation for comma-delimited multiple-flag #614
Conversation
test/parser/parse.test.ts
Outdated
it('allowed options on multiple', async () => { | ||
const out = await parse(['--foo', 'a', '--foo=b'], { | ||
flags: { | ||
foo: Flags.custom({multiple: true, parse: async i => i, options: ['a', 'b']})(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for using Flag.custom
and defining a parse
? It's not an issue, it just would be more concise to do this:
Flags.string({multiple: true, options: ['a', 'b']})
src/parser/parse.ts
Outdated
const values = await Promise.all( | ||
input.split(flag.delimiter).map(async v => this._parseFlag(v.trim(), flag, token)), | ||
input.split(flag.delimiter).map(async v => this._parseFlag(v.trim().replace(/^"(.*)"$/, '$1'), flag, token)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mshanemc should this also consider signle quotes, 'a b' 'c d'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I think so. posix-shells could
side note about error messages assertion changes:
test cases would run find from
yarn test
but fail when running the individual test becuase of ASCII color codes in the results. They've been modified to "include" the expected strings to make them color-blindfixes forcedotcom/cli#1936