Skip to content

Commit 80f8afb

Browse files
committed
Merge pull request DefinitelyTyped#6024 from nabeix/commander
update commander
2 parents 4551ee0 + e29d691 commit 80f8afb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

commander/commander-tests.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ program.on('--help', () => {
9595
console.log('');
9696
});
9797

98+
program
99+
.command('allow-unknown-option')
100+
.allowUnknownOption()
101+
.action(() => {
102+
console.log('unknown option is allowed');
103+
});
104+
98105
program.parse(process.argv);
99106

100107
console.log('stuff');

commander/commander.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ declare module commander {
158158
option(flags:string, description?:string, fn?:(arg1:any, arg2:any)=>void, defaultValue?:any):ICommand;
159159
option(flags:string, description?:string, defaultValue?:any):ICommand;
160160

161+
/**
162+
* Allow unknown options on the command line.
163+
*
164+
* @param {Boolean} arg if `true` or omitted, no error will be thrown
165+
* for unknown options.
166+
* @api public
167+
*/
168+
allowUnknownOption(arg?: boolean):ICommand;
169+
161170
/**
162171
* Parse `argv`, settings options and invoking commands when defined.
163172
*

0 commit comments

Comments
 (0)