Create a new method as command has specific requirements.

        There is a handful of the TMSH global commands supported,
        so this method requires them as a parameter.

        :raises: InvalidCommand
762461
def _exec_cmd(self, command, **kwargs):
        

        kwargs['command'] = command
        self._check_exclusive_parameters(**kwargs)
        requests_params = self._handle_requests_params(kwargs)
        session = self._meta_data['bigip']._meta_data['icr_session']
        response = session.post(
            self._meta_data['uri'], json=kwargs, **requests_params)
        new_instance = self._stamp_out_core()
        new_instance._local_update(response.json())
        if 'commandResult' in new_instance.__dict__:
            new_instance._check_command_result()

        return new_instance
489139
def call
      if arguments.valid?
        Qiita::Commands::Request.new(arguments)
      else
        Qiita::Commands::Error.new(arguments)
      end
    end
997154
def create(self, name, *args, **kwargs):
        """"""
        tokens = name.split()

        if len(tokens) > 1 and (len(args) > 0 or len(kwargs) > 0):
            msg  = 'A Cmd may be created with either positional arguments '
            msg += '(passed as a string or a Python list) or keyword '
            msg += 'arguments, but not both.'
            raise TypeError(msg)

        if len(tokens) > 1:
            name = tokens[0]
            args = [ util.toNumber(t, t) for t in tokens[1:] ]

        defn = self.get(name, None)

        if defn is None:
            raise TypeError('Unrecognized command: %s' % name)

        return createCmd(defn, *args, **kwargs)
930220
def add_command(self, func, name=None, doc=None):
        
        command = Command(func, doc)
        name = name or func.__name__
        self._commands[name] = command
716811
def macro_create(self, args: argparse.Namespace) -> None:
        """"""

        # Validate the macro name
        valid, errmsg = self.statement_parser.is_valid_command(args.name)
        if not valid:
            self.perror("Invalid macro name: {}".format(errmsg), traceback_war=False)
            return

        if args.name in self.get_all_commands():
            self.perror("Macro cannot have the same name as a command", traceback_war=False)
            return

        if args.name in self.aliases:
            self.perror("Macro cannot have the same name as an alias", traceback_war=False)
            return

        utils.unquote_redirection_tokens(args.command_args)

        # Build the macro value string
        value = args.command
        if args.command_args:
            value += ' ' + ' '.join(args.command_args)

        # Find all normal arguments
        arg_list = []
        normal_matches = re.finditer(MacroArg.macro_normal_arg_pattern, value)
        max_arg_num = 0
        arg_nums = set()

        while True:
            try:
                cur_match = normal_matches.__next__()

                # Get the number string between the braces
                cur_num_str = (re.findall(MacroArg.digit_pattern, cur_match.group())[0])
                cur_num = int(cur_num_str)
                if cur_num < 1:
                    self.perror("Argument numbers must be greater than 0", traceback_war=False)
                    return

                arg_nums.add(cur_num)
                if cur_num > max_arg_num:
                    max_arg_num = cur_num

                arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=False))

            except StopIteration:
                break

        # Make sure the argument numbers are continuous
        if len(arg_nums) != max_arg_num:
            self.perror("Not all numbers between 1 and {} are present "
                        "in the argument placeholders".format(max_arg_num), traceback_war=False)
            return

        # Find all escaped arguments
        escaped_matches = re.finditer(MacroArg.macro_escaped_arg_pattern, value)

        while True:
            try:
                cur_match = escaped_matches.__next__()

                # Get the number string between the braces
                cur_num_str = re.findall(MacroArg.digit_pattern, cur_match.group())[0]

                arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=True))
            except StopIteration:
                break

        # Set the macro
        result = "overwritten" if args.name in self.macros else "created"
        self.macros[args.name] = Macro(name=args.name, value=value, minimum_arg_count=max_arg_num, arg_list=arg_list)
        self.poutput("Macro '{}' {}".format(args.name, result))
1012559
def _check_command_parameters(self, **kwargs):
        
        rset = self._meta_data['required_command_parameters']
        check = _missing_required_parameters(rset, **kwargs)
        if check:
            error_message = 'Missing required params: %s' % check
            raise MissingRequiredCommandParameter(error_message)
114537
def add_command(self, cmd, name=None):
        
        name = name or cmd.name
        if name is None:
            raise TypeError('Command has no name.')
        self.commands[name] = cmd
58323
def _execute(self, func, command, **new_attributes):
        
        if self._cfg_factory:
            # if we have a cfg_factory
            try:
                # we try to load a config with the factory
                if self.cfg_file:
                    self.cfg = self._cfg_factory(self.cfg_file)
            except Exception as error:
                # raise se exception
                self._cfg_error(error)
        # let's get command(function) argspec
        arg_specs = inspect.getargspec(command)
        if arg_specs.defaults:
            # if we have defaults
            # count defaults arguments
            count = len(arg_specs.defaults)
            # get arguments names
            args_names = arg_specs.args[:count]
            # get keyword arguments names
            kwargs_name = arg_specs.args[count:]
        else:
            # else all names are the args only
            args_names = arg_specs.args
            # and keyword arguments is empty
            kwargs_name = []
        pargs = []
        kwargs = {}
        # for every argument in argument names
        for name in args_names:
            if name == 'args':
                # if argument name is *special name* **args**
                # we append a reference to self.args
                pargs.append(self.args)
            elif name == 'self':
                # else if argment name is *special name* **self**
                if ArgParseInated in inspect.getmro(func.__cls__):
                    # if the class that holds the function is subclass of
                    # ArgParseInated we'll instantiate it, passing some
                    # parameter
                    pargs.append(func.__cls__(self, **new_attributes))
                else:
                    # else we'll instatiate the class without parameters
                    pargs.append(func.__cls__())
            else:
                # else we'll append the argument getting it from the self.args
                pargs.append(getattr(self.args, name))
        # for every argument in keyword arguments
        for name in kwargs_name:
            if name == 'args':
                # if argument name is *special name* **args**
                # we set for the arg a reference to self.args
                kwargs[name] = self.args
            elif name in self.args:
                # else if name is in self.args we'll set the relative value.
                kwargs[name] = getattr(self.args, name)
        # set the **global** write function
        setattr(__builtin__, self._write_name, self.write)
        # set the **global** write line function
        setattr(__builtin__, self._write_line_name, self.writeln)
        # let's setup something.
        for setup_func in self.setup:
            setup_func(self)
        # call event before_execute
        self._self_event('before_execute', command, *pargs, **kwargs)
        # if events returns a non None value we use it as retrval.
        retval, pargs, kwargs = self._call_event(
            'before_execute', command, pargs, kwargs)
        # if before_execute event returns None go on with command
        if retval is None:
            # let's execute the command and assign the returned value to retval
            retval = command(*pargs, **kwargs)
            # call event after_execute
            self._call_event('after_execute', command, pargs, kwargs)
            self._self_event('after_execute', command, *pargs, **kwargs)
        if self.auto_exit:
            # if we have auto_exit is True
            if retval is None:
                self._self_event(
                    'before_exit_ok', command, retval=EXIT_OK, *pargs, **kwargs)
                # if retval is None we'll assume it's EXIT_OK
                self.exit(EXIT_OK)
            elif isinstance(retval, basestring):
                self._self_event('before_exit_ok', command, retval=retval, *pargs, **kwargs)
                # else if retval is a string we will exit with the message and
                # ERRORCODE is equal to 0
                self.exit(EXIT_OK, retval)
            elif isinstance(retval, int):
                if retval == EXIT_OK:
                    self._self_event('before_exit_ok', command, retval=retval, *pargs, **kwargs)
                else:
                    self._self_event('before_exit_error', command, retval=retval, *pargs, **kwargs)
                # else if retval is an integer we'll exits with it as ERRORCODE
                self.exit(retval)
            elif isinstance(retval, (tuple, list,)):
                self._self_event('before_exit_error', command, retval=retval, *pargs, **kwargs)
                # if retval is a tuple or a list we'll exist with ERRORCODE and
                # message
                self.exit(retval[0], retval[1])
            self._self_event('before_exit', command, retval=retval, *pargs, **kwargs)
            self.exit()
        else:
            # else if auto_exit is not True
            # we'll simply return  retval
            return retval
746869
private function createFromCommand()
    {
        $command = BranchCommand::getInstance($this->getRepository())->listBranches();
        $outputLines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
        foreach ($outputLines as $outputLine) {
            $matches = static::getMatches($outputLine);

            if ($this->name === $matches[1]) {
                $this->parseOutputLine($outputLine);

                return;
            }
        }

        throw new InvalidBranchNameException(sprintf('The %s branch doesn\'t exists', $this->name));
    }
789933
def make_command(command: Callable) -> Callable:
    """"""
    @wraps(command)
    def actualcommand(self, *args, **kwds):  # pylint: disable=missing-docstring
        data = command(self, *args, **kwds)
        name = command.__name__[3:]
        signal = '{uuid}{sep}{event}'.format(
            uuid=self._uuid,  # pylint: disable=protected-access
            sep=SEPARATOR,
            event=name
        )
        if flask.has_request_context():
            emit(signal, {'data': pack(data)})
        else:
            sio = flask.current_app.extensions['socketio']
            sio.emit(signal, {'data': pack(data)})
        eventlet.sleep()

    return actualcommand
539237
function addCommand(descriptor){
	// Check descriptor type.
	var err = {};
	if( !checkDescriptor(descriptor, err) ){
		logger.error(
			'The command descriptor is invalid.',
			new Error('[command.io] Invalid command descriptor ("'+err.key+'": expected "'+err.expect+'", have "'+err.type+'").')
		);
		logger.error('Please check this doc: https://github.com/Techniv/node-command-io/wiki/Command-descriptor-refactoring');
		return module.exports;
	}

	var name = descriptor.name;
	descriptor.controller = new CommandController(descriptor);

    // Index the command descriptor
    commandDescriptors[name] = descriptor;

    // Chain addCommand
    return module.exports;
}
394766
def create(self, key=None, label=None):
        
        key = '%s' % key
        url = self.bitbucket.url('SET_SSH_KEY')
        return self.bitbucket.dispatch('POST', url, auth=self.bitbucket.auth, key=key, label=label)
1245430
def process_command(command: CommandInput, matrix: VarMatrix) -> List[Command]:
    
    assert command is not None
    if isinstance(command, str):
        command_list = [Command(command, variables=variables) for variables in matrix]
    elif isinstance(command, list):
        command_list = [Command(command, variables=variables) for variables in matrix]
    else:
        if command.get("command") is not None:
            cmd = command.get("command")
        else:
            cmd = command.get("cmd")
        creates = str(command.get("creates", ""))
        requires = str(command.get("requires", ""))

        assert isinstance(cmd, (list, str))
        command_list = [
            Command(cmd, variables, creates, requires) for variables in matrix
        ]
    return uniqueify(command_list)
392899
def method_missing mtd, *args
      if mtd.to_s.chars.to_a.last == '='
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1
        attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first
      else
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 0)" if args.length != 0
        attributes[mtd.to_s]
      end
    end
418859
def define_command(name = nil, &block)
      # Execute DSL
      dsl = Cri::CommandDSL.new
      dsl.name name unless name.nil?
      if [-1, 0].include? block.arity
        dsl.instance_eval(&block)
      else
        yield(dsl)
      end

      # Create command
      cmd = dsl.command
      add_command(cmd)
      cmd
    end
506460
def create_commands_map
      # Require all the ruby command files
      command_file_paths.each do |file|
        require file

        # Get basename for the file without the extension
        basename = get_basename_from_file(file)

        # Camelcase the basename to be the klass name
        klass_name = camelize(basename)

        # return the command klass for this klass_name
        command_klass = Conify::Command.const_get(klass_name)

        # For each of the user-defined methods inside this class, create a command for it
        manually_added_methods(command_klass).each { |method|
          register_command(basename, method.to_s, command_klass, global: basename == 'global')
        }
      end
    end
1353898
def create_cmd(self, args):
        '''
        
        '''
        cmd = args.get('cmd_create')
        if cmd == 'conf':
            conf_file = args['conf_file']
            conf_id = args['id']
            return self.load_xml_conf(conf_file, conf_id)
        else:
            print("Error: Create %s is invalid or not implemented" % cmd)