From 733784804d0df1a99be675dece07ff3c156746b4 Mon Sep 17 00:00:00 2001 From: Taylor Baldwin Date: Thu, 14 Jul 2022 12:11:16 -0400 Subject: [PATCH] fix bug where custom flags have multiple=false (#414) Co-authored-by: Mike Donnalley --- src/parser/flags.ts | 2 +- test/parser/parse.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parser/flags.ts b/src/parser/flags.ts index 286e06ea3..b6bdc8d40 100644 --- a/src/parser/flags.ts +++ b/src/parser/flags.ts @@ -18,7 +18,7 @@ export function build(defaults: Partial>): Definition { ...defaults, ...options, input: [] as string[], - multiple: Boolean(options.multiple), + multiple: Boolean(options.multiple === undefined ? defaults.multiple : options.multiple), type: 'option', } as any } diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts index b705a033d..0fc6d48ef 100644 --- a/test/parser/parse.test.ts +++ b/test/parser/parse.test.ts @@ -327,6 +327,14 @@ See more help with --help`) expect(out.flags.baz.toUpperCase()).to.equal('D') expect(out.flags.bar.join('|')).to.equal('a|b') }) + it('parses multiple flags on custom flags', async () => { + const out = await parse(['--foo', 'a', '--foo=b'], { + flags: { + foo: flags.option({multiple: true, parse: async i => i}), + }, + }) + expect(out.flags).to.deep.include({foo: ['a', 'b']}) + }) }) describe('strict: false', () => {