command()

in src/program.js [77:105]


  command(name, description, executor, commandOptions = {}) {
    this.options[camelCase(name)] = commandOptions;

    this.yargs.command(name, description, (yargsForCmd) => {
      if (!commandOptions) {
        return;
      }
      return (
        yargsForCmd
          // Make sure the user does not add any extra commands. For example,
          // this would be a mistake because lint does not accept arguments:
          // web-ext lint ./src/path/to/file.js
          .demandCommand(
            0,
            0,
            undefined,
            'This command does not take any arguments',
          )
          .strict()
          .exitProcess(this.shouldExitProgram)
          // Calling env() will be unnecessary after
          // https://github.com/yargs/yargs/issues/486 is fixed
          .env(envPrefix)
          .options(commandOptions)
      );
    });
    this.commands[name] = executor;
    return this;
  }