From 9b38cf7fedc86157f95dc814658a3e39699bd914 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 8 Sep 2022 09:43:28 -0600 Subject: [PATCH 1/2] fix: throw if unexpected argument --- src/parser/parse.ts | 2 +- test/parser/parse.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/parser/parse.ts b/src/parser/parse.ts index a7d965e2..bee68e18 100644 --- a/src/parser/parse.ts +++ b/src/parser/parse.ts @@ -258,7 +258,7 @@ export class Parser { expect(out.args).to.deep.equal({foo: 'arg1', bar: 'arg2'}) }) + it('should throw if unexpected argument is provided', async () => { + try { + await parse(['arg1'], {}) + expect.fail('should have thrown') + } catch (error) { + const err = error as CLIError + expect(err.message).to.include('Unexpected argument: arg1') + } + }) + describe('output: array', () => { it('--bool', async () => { const out = await parse(['--bool'], { From e4276dd0de68fedc6cadd2704cfd4691df94ff9e Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 8 Sep 2022 10:39:59 -0600 Subject: [PATCH 2/2] chore: formatting --- src/interfaces/parser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interfaces/parser.ts b/src/interfaces/parser.ts index 7d663573..ea111027 100644 --- a/src/interfaces/parser.ts +++ b/src/interfaces/parser.ts @@ -118,7 +118,7 @@ export type FlagProps = { /** * Accept an environment variable as input */ - env?: string; + env?: string; /** * If true, the flag will not be shown in the help. */ @@ -142,7 +142,7 @@ export type FlagProps = { /** * Define complex relationships between flags. */ - relationships?: Relationship[]; + relationships?: Relationship[]; } export type BooleanFlagProps = FlagProps & {