add command definition to current template
@param commandName
@param {Function} fn command definition
501774
function (commandName, fn) {
            var config = this.config;
            config.commands = config.commands || {};
            config.commands[commandName] = fn;
        }
677785
function (command) {
    if (!command || !_.isObject(command)) {
      var err = new Error('Please inject a valid command object!');
      debug(err);
      throw err;
    }

    if (!command.payload && command.payload !== '') {
      command.payload = this.defaultCommandPayload;
    }

    command.defineAggregate(this);

    if (this.commands.indexOf(command) < 0) {
      this.commands.push(command);
    }
  }
1226955
public synchronized void addCommand(final CommandImpl command) throws DevFailed {
        CommandImpl result = null;
        for (final CommandImpl cmd : commandList) {
            if (command.getName().equalsIgnoreCase(cmd.getName())) {
                result = command;
                break;
            }
        }
        if (result == null) {
            commandList.add(command);
            // set default polling configuration
            if (cmdPollRingDepth.containsKey(command.getName().toLowerCase(Locale.ENGLISH))) {
                command.setPollRingDepth(cmdPollRingDepth.get(command.getName().toLowerCase(Locale.ENGLISH)));
            } else {
                command.setPollRingDepth(pollRingDepth);
            }
        }
    }
734061
function _preCommand(commands) {
  commander.on('--help', function () {

    var hasExample = _.map(_.values(commands), 'examples')
      .filter(function (elem) {
        return elem !== undefined;
      });
    if (hasExample.length > 0) {
      hasExample = hasExample.reduce(function (a, b) {
        return a.concat(b);
      });
    }
    hasExample = hasExample.length > 0;

    if (hasExample) {

      console.log('  Examples:\n');

      Object.keys(commands).forEach(function (command) {
        if (!_.isEmpty(commands[command].examples)) {
          console.log('    %s:', command);
          commands[command].examples.forEach(function (example) {
            console.log('      %s', example);
          });
        }
      });
    }
  });
}
960811
function showCommandsOnCmdEditor (config) {

	console.log(colors.bold('\nAvailable Commands for ' + config.deviceName + ':\n'));

	// Iterate the each commands
	var commands = config.commands || {};
	if (Object.keys(commands).length == 0) {
		console.log ('\nThere is no command.');
	} else {
		for (var name in commands) {
			var desc = commands[name].description || '';
			console.log(colors.bold('\n' + name + '') + '\n  ' + desc + '\n');

			// Iterate the each arguments
			var args = commands[name].args || {};
			if (Object.keys(args).length == 0) {
				console.log ('\tThe arguments of this command are not defined');
			} else {
				for (var arg_name in args) {
					var arg_spec = args[arg_name] || '';
					console.log('\t* ' + arg_name + ' - ' + arg_spec);
				}
			}

		}
	}

	console.log('\n');

	// Done
	return new Promise(function (resolve, reject) {
		resolve();
	});

}
1087563
function addCommand() {

        var menu                    = Menus.getMenu(Menus.AppMenuBar.FILE_MENU),
            INSTALL_COMMAND_SCRIPT  = "file.installCommandScript";

        CommandManager.register(Strings.CMD_LAUNCH_SCRIPT_MAC, INSTALL_COMMAND_SCRIPT, handleInstallCommand);
        menu.addMenuDivider();
        menu.addMenuItem(INSTALL_COMMAND_SCRIPT);
    }
774466
function prepare_command(input_args) {

  let command = null;
  const args = Array.prototype.slice.call(input_args);
  const funcOrCommand = args.shift();

  if (is(funcOrCommand, Command))
    command = funcOrCommand;

  if (is(funcOrCommand, Function))
    command = new Command(funcOrCommand);

  if (!command)
    throw new Error(Errors.BadExecuteArgument);

  command.arguments = args;
  command.result_file = null;

  return command;

}
543958
function Command (name, cli, action) {
  if (!(this instanceof Command)) {
    return new Command(name, cli, action)
  }
  this.name = name
  this.cli = cli
  this.action = action
}
884116
function addCommandType(engine, name, Type) {
        engine.commandTypes[name] = Type;
        Type.prototype.type = name;
    }
314371
def add_cmd(self, name, help=None, func=None):
        
        if self.subparsers is None:
            self.subparsers = self.add_subparsers(
                title="sub-commands",
                help=help or 'sub-commands',
            )

        parser = self.subparsers.add_parser(
            name,
            help=help,
        )
        if func is not None:
            parser.set_defaults(_func=func)
        return parser
1370481
function include(list) {
    var cmd, clazz, i, file, j, name, newname;
    for(i = 0;i < list.length;i++) {
      file = list[i];
      try {
        clazz = require(file);
        // assume it is already instantiated
        if(typeof clazz === 'object') {
          cmd = clazz;
        }else{
          cmd = new clazz(clazz.definition);
        }

        // rename and delete commands
        if(cmd && cmd.definition && cmd.definition.name) {
          for(j = 0;j < rename.length;j++) {
            name = rename[j][0];
            newname = rename[j][1];
            if(name
              && name.toLowerCase() === cmd.definition.name.toLowerCase()) {
              newname = (newname || '').toLowerCase();
              // actually renaming
              if(newname) {
                log.warning(
                  'rename command %s -> %s', cmd.definition.name, newname);
                cmd.definition.name = newname;
              // deleting the command, mark as deleted with false
              }else{
                log.warning(
                  'deleted command %s (%s)', cmd.definition.name, file);
                commands[cmd.definition.name] = false;
                // clear the module cache
                delete require.cache[file];
              }
              break;
            }
          }
        }

        // deleted the command
        if(!require.cache[file]) continue;

        // sanity checks
        if(!(cmd instanceof CommandExec)) {
          throw new Error(
            util.format(
              'module does not export a command exec instance (%s)', file));
        }else if(
          !cmd.definition
          || !cmd.definition.constructor
          || cmd.definition.constructor.name !== Command.name) {
          throw new Error(
            util.format(
              'command does not have a valid definition (%s)', file));
        }else if(!cmd.definition.name) {
          throw new Error(
            util.format(
              'command definition does not have a name (%s)', file));
        }

        if(opts.override !== true && commands[cmd.definition.name]) {
          throw new Error(util.format(
              'duplicate command %s (%s)', cmd.definition.name, file));
        }

        log.debug('loaded %s (%s)', cmd.definition.name, file);

        // map of command names to command exec handlers
        commands[cmd.definition.name] = cmd;
      }catch(e) {
        return complete(e);
      }
    }
    complete();
  }
233371
function Command(f, params, path) {
	this.f = f;
	this.params = params;
	this.path = path==null ? true : path;
}
180548
public function addCustomCommand($command)
    {
        $name = lcfirst(class_basename($command));

        $this->customCommands[$name] = $command;
    }
605735
function Command(name, parent) {
  if (!(this instanceof Command)) {
    return new Command();
  }
  this.commands = [];
  this.options = [];
  this._args = [];
  this._aliases = [];
  this._name = name;
  this._relay = false;
  this._hidden = false;
  this._parent = parent;
  this._mode = false;
  this._catch = false;
  this._help = undefined;
  this._init = undefined;
  this._after = undefined;
  this._allowUnknownOptions = false;
}
768278
function _handleCommandRegistered(event, command) {
        var commandId   = command.getID(),
            defaults    = KeyboardPrefs[commandId];

        if (defaults) {
            addBinding(commandId, defaults);
        }
    }
413093
def add_command(self, cmd_name, *args):
        """"""
        self.__commands.append(Command(cmd_name, args))
307072
function( buttonName, commandName, dialogFile )
		{
			editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) );

			editor.ui.addButton( buttonName,
				{
					label : lang.common[ buttonName.charAt(0).toLowerCase() + buttonName.slice(1) ],
					command : commandName
				});
			CKEDITOR.dialog.add( commandName, dialogFile );
		}