From e29d691d41dca6626171ee7282b0bdaeb15d38b3 Mon Sep 17 00:00:00 2001 From: Yusuke Watanabe Date: Fri, 25 Sep 2015 00:34:41 +0900 Subject: [PATCH] update to support allowUnknownOption() --- commander/commander-tests.ts | 7 +++++++ commander/commander.d.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/commander/commander-tests.ts b/commander/commander-tests.ts index f2457901da..135ad8bf02 100644 --- a/commander/commander-tests.ts +++ b/commander/commander-tests.ts @@ -95,6 +95,13 @@ program.on('--help', () => { console.log(''); }); +program + .command('allow-unknown-option') + .allowUnknownOption() + .action(() => { + console.log('unknown option is allowed'); + }); + program.parse(process.argv); console.log('stuff'); diff --git a/commander/commander.d.ts b/commander/commander.d.ts index 09d7966596..278a491a62 100644 --- a/commander/commander.d.ts +++ b/commander/commander.d.ts @@ -158,6 +158,15 @@ declare module commander { option(flags:string, description?:string, fn?:(arg1:any, arg2:any)=>void, defaultValue?:any):ICommand; option(flags:string, description?:string, defaultValue?:any):ICommand; + /** + * Allow unknown options on the command line. + * + * @param {Boolean} arg if `true` or omitted, no error will be thrown + * for unknown options. + * @api public + */ + allowUnknownOption(arg?: boolean):ICommand; + /** * Parse `argv`, settings options and invoking commands when defined. *