MCPcopy
hub / github.com/mozilla/web-ext / command

Method command

src/program.js:77–105  ·  view source on GitHub ↗
(name, description, executor, commandOptions = {})

Source from the content-addressed store, hash-verified

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.

Callers 4

mainFunction · 0.95
makeArgvFunction · 0.95
test.config.jsFile · 0.80
test.program.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected