update to support allowUnknownOption()

This commit is contained in:
Yusuke Watanabe 2015-09-25 00:34:41 +09:00
parent 32029fcb4e
commit e29d691d41
2 changed files with 16 additions and 0 deletions

View File

@ -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');

View File

@ -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.
*