From 6e04e997a2030bc97c0096b830503cb2e8c76fef Mon Sep 17 00:00:00 2001 From: Thomas Sawkins Date: Wed, 17 Oct 2018 16:45:18 +1100 Subject: [PATCH 1/2] use default values for options --- src/commander.test.ts | 2 +- src/commander.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commander.test.ts b/src/commander.test.ts index 66456b0..2d930df 100644 --- a/src/commander.test.ts +++ b/src/commander.test.ts @@ -142,7 +142,7 @@ describe('src/commander', () => { }); expect(action).toBeDefined(); await expect(action('john', undefined, {})).resolves.toBeUndefined(); - expect(loginHandler).toHaveBeenCalledWith({ username: 'john' }); + expect(loginHandler).toHaveBeenCalledWith({ username: 'john', rememberMeFor: 7 }); // tslint:disable-next-line:no-console expect(console.error).toHaveBeenCalledWith( expect.stringMatching(/Computer says no/gi) diff --git a/src/commander.ts b/src/commander.ts index 9bf7e4d..4230230 100644 --- a/src/commander.ts +++ b/src/commander.ts @@ -63,7 +63,10 @@ function getParams( const optionValues = args[paramIndex]; for (const option of options) { - params[option.name.toString()] = optionValues[option.name]; + const value = optionValues[option.name]; + if (value !== undefined) { + params[option.name.toString()] = value; + } } return params; From 9f2241f6b399a64ecdbd7cd994174dc75ffaf65f Mon Sep 17 00:00:00 2001 From: Thomas Sawkins Date: Wed, 17 Oct 2018 16:46:13 +1100 Subject: [PATCH 2/2] fix example to display decimal places correctly --- example/commands/add.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/example/commands/add.ts b/example/commands/add.ts index 9585817..adb7a4c 100644 --- a/example/commands/add.ts +++ b/example/commands/add.ts @@ -27,6 +27,7 @@ export class AddCommand implements Command { const format = (val: number) => val.toLocaleString(undefined, { useGrouping: thousandSeparators, + minimumFractionDigits: decimalPlaces, maximumFractionDigits: decimalPlaces });