(name, description, executor, commandOptions = {})
| 75 | } |
| 76 | |
| 77 | command(name, description, executor, commandOptions = {}) { |
| 78 | this.options[camelCase(name)] = commandOptions; |
| 79 | |
| 80 | this.yargs.command(name, description, (yargsForCmd) => { |
| 81 | if (!commandOptions) { |
| 82 | return; |
| 83 | } |
| 84 | return ( |
| 85 | yargsForCmd |
| 86 | // Make sure the user does not add any extra commands. For example, |
| 87 | // this would be a mistake because lint does not accept arguments: |
| 88 | // web-ext lint ./src/path/to/file.js |
| 89 | .demandCommand( |
| 90 | 0, |
| 91 | 0, |
| 92 | undefined, |
| 93 | 'This command does not take any arguments', |
| 94 | ) |
| 95 | .strict() |
| 96 | .exitProcess(this.shouldExitProgram) |
| 97 | // Calling env() will be unnecessary after |
| 98 | // https://github.com/yargs/yargs/issues/486 is fixed |
| 99 | .env(envPrefix) |
| 100 | .options(commandOptions) |
| 101 | ); |
| 102 | }); |
| 103 | this.commands[name] = executor; |
| 104 | return this; |
| 105 | } |
| 106 | |
| 107 | setGlobalOptions(options) { |
| 108 | // This is a convenience for setting global options. |
no outgoing calls
no test coverage detected