(commandName: string, setter: ToolCommandFlagsSetter<T>)
| 41 | } |
| 42 | |
| 43 | export function withFlags<T>(commandName: string, setter: ToolCommandFlagsSetter<T>) { |
| 44 | if (typeof commandName !== 'string') { |
| 45 | log('apiCommandNameInvalid_0200', 'flags'); |
| 46 | } else if (typeof setter !== 'function') { |
| 47 | log('apiArgumentInvalid_0201', 'setter', 'flags'); |
| 48 | } else { |
| 49 | findAll(commandName, (command) => { |
| 50 | const current = command.flags || ((x) => x); |
| 51 | command.flags = (argv) => current(setter(argv)); |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | return this; |
| 56 | } |
| 57 | |
| 58 | export function wrapCommand<U>(commandName: string, wrapper: ToolCommandWrapper<U>) { |
| 59 | if (typeof commandName !== 'string') { |
no test coverage detected