diff --git a/src/interfaces/parser.ts b/src/interfaces/parser.ts index 6b4796272..797de0f91 100644 --- a/src/interfaces/parser.ts +++ b/src/interfaces/parser.ts @@ -175,7 +175,7 @@ export type OptionFlagProps = FlagProps & { multiple?: boolean; } -export type FlagParser = (input: I, context: any, opts: P & OptionFlag) => Promise +export type FlagParser = (input: I, context: any, opts: P & OptionFlag) => Promise export type FlagBase = FlagProps & { parse: FlagParser; diff --git a/src/parser/parse.ts b/src/parser/parse.ts index 58557880e..0400d6498 100644 --- a/src/parser/parse.ts +++ b/src/parser/parse.ts @@ -201,7 +201,7 @@ export class Parser { + const out = await parse( + ['--foo', './a.txt,./b.txt', '--foo', './c.txt', '--', '15'], + { + args: [{name: 'num'}], + flags: {foo: flags.string({ + multiple: true, + parse: async input => input.split(',').map(i => i.trim()), + })}, + }, + ) + expect(out.flags).to.deep.include({ + foo: ['./a.txt', './b.txt', './c.txt'], + }) + expect(out.args).to.deep.include({num: '15'}) + }) }) describe('defaults', () => {