Search command in command list.
 Return command object if search success,
 else return nil.
 cmdlist -- array with command objects.
 cmd -- string with command name from ARGV.
426289
def command_search( cmdlist, cmd )
      cmdlist.each do |c|
	c.init
	return c if c.name == cmd
      end
      return nil
    end
1013268
def request(self, cmds):
        
        if isinstance(cmds, list):
            cmd = '\n'.join(cmds)
        elif isinstance(cmds, str) or isinstance(cmds, unicode):
            cmd = cmds

        node = etree.Element(qualify('CLI', BASE_NS_1_0))

        etree.SubElement(node, qualify('Execution',
                                       BASE_NS_1_0)).text = cmd

        return self._request(node)
620807
def get_command_class(self, cmd):
        
        try:
            cmdpath = self.registry[cmd]
        except KeyError:
            raise CommandError("No such command %r" % cmd)
        if isinstance(cmdpath, basestring):
            Command = import_class(cmdpath)
        else:
            Command = cmdpath
        return Command
951153
def get_command(self, ctx, cmd_name):
        
        if cmd_name not in self._commands:
            logger.error("Command %s not available", cmd_name)
            return

        pkg_name = self._commands[cmd_name]

        try:
            mod = importlib.import_module(pkg_name)
        except ImportError:
            logger.exception("Command '%s' is not configured correctly. Unable to import '%s'", cmd_name, pkg_name)
            return

        if not hasattr(mod, "cli"):
            logger.error("Command %s is not configured correctly. It must expose an function called 'cli'", cmd_name)
            return

        return mod.cli
1215694
def _get_cmd(command, arguments):
    """"""
    if arguments is None:
        arguments = []
    if command.endswith(".py") or command.endswith(".pyw"):
        return [sys.executable, command] + list(arguments)
    else:
        return [command] + list(arguments)
1212388
def cli_cmd_to_string(args):
    
    if isinstance(args, basestring):
        # Return directly if it's already a string.
        return args
    return ' '.join([pipes.quote(arg) for arg in args])
1275873
def find_command(cmd, path=None, pathext=None):
    
    if path is None:
        path = os.environ.get('PATH', '').split(os.pathsep)
    if isinstance(path, string_types):
        path = [path]

    # check if there are path extensions for Windows executables
    if pathext is None:
        pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
        pathext = pathext.split(os.pathsep)

    # don't use extensions if the command ends with one of them
    for ext in pathext:
        if cmd.endswith(ext):
            pathext = ['']
            break

    # check if we find the command on PATH
    for p in path:
        f = os.path.join(p, cmd)
        if os.path.isfile(f):
            return f
        for ext in pathext:
            fext = f + ext
            if os.path.isfile(fext):
                return fext
    return None
1236972
def command(command, options)
      options = {
          'print_command' => false,
          'failure_message' => "required command '#{command}' is not available."
      }.merge(string_keys(options))
      system_exit_on_error("which #{command}", options)
    end
687081
def default_command(command_name = nil)
      if command_name
        if commands.key?(command_name)
          @default_command = commands[command_name] if command_name
          @default_command
        else
          raise ArgumentError, "'#{command_name}' couldn't be found in this command's list of commands."
        end
      else
        @default_command
      end
    end
1175969
def cmd(commands, opts={})
      key_by = opts.delete(:key_by) || :instance_id
      results = {}
      threads = nodes.collect do |n|
        puts "result for #{n.instance_id} ==> n.ssh(#{commands.inspect}, #{opts.inspect})"
        Thread.new{ results[ n.send(key_by) ] = n.ssh(commands, opts) }
      end
      threads.each{ |aThread| aThread.join }
      results
    end
862684
def display_commands( cmdlist )
      maxlen = 0
      cmdlist.each do |cmd|
	maxlen = cmd.name.length if cmd.name.length > maxlen
      end
      cmdlist.each do |cmd|
	print '  ' + cmd.name
	print "#{' ' * (maxlen - cmd.name.length)}  # "
	puts cmd.brief
      end
    end
1150507
function (cmd, callback) {
    var cmdName = dotty.get(cmd, this.definitions.command.name);

    var err;
    if (!cmdName) {
      err = new Error('command has no command name in ' + this.definitions.command.name);
      debug(err);
      return callback(err);
    }

    var version = 0;
    if (!!this.definitions.command.version) {
      version = dotty.get(cmd, this.definitions.command.version);
    }

    var command = this.getCommand(cmdName, version);
    if (!command) {
      err = new Error('Command "' + cmdName + '" not found!');
      debug(err);
      return callback(err);
    }

    if (command.validate.length >= 2) {
      return command.validate(cmd, callback);
    }

    try {
      callback(command.validate(cmd));
    } catch (e) {
      callback(e);
    }
  }
866
def fetch_command(self, subcommand):
        
        # Get commands outside of try block to prevent swallowing exceptions
        commands = get_commands()
        try:
            app_name = commands[subcommand]
        except KeyError:
            # This might trigger ImproperlyConfigured (masked in get_commands)
            settings.INSTALLED_APPS
            sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" %
                (subcommand, self.prog_name))
            sys.exit(1)
        if isinstance(app_name, BaseCommand):
            # If the command is already loaded, use it directly.
            klass = app_name
        else:
            klass = load_command_class(app_name, subcommand)
        return klass
259754
def _make_cmd_list(cmd_list):
    
    cmd = ''
    for i in cmd_list:
        cmd = cmd + '"' + i + '",'
    cmd = cmd[:-1]
    return cmd
37601
def help(self, event, command_name=None):
        
        if command_name is None:
            return ("Type !commands for a list of all commands. Type "
                    "!help [command] to see help for a specific command.")
        try:
            command = self.commands_dict()[command_name]
        except KeyError:
            return "%s is not a command" % command_name

        argspec = getargspec(command)
        args = argspec.args[2:]
        defaults = argspec.defaults or []
        for i in range(-1, -len(defaults) - 1, -1):
            args[i] = "%s [default: %s]" % (args[i], defaults[i])
        args = ", ".join(args)
        help = getdoc(command).replace("\n", " ")
        return "help for %s: (args: %s) %s" % (command_name, args, help)
334635
private RegisteredCommand searchCommands(String cmdOwner, HttpMethod method, String uri,
                                             String query, Map<String, String> variableMap) {
        Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = getCmdEvalMap(cmdOwner);
        if (evalMap == null) {
            return null;
        }
        
        // Find the sorted command set for the given HTTP method.
        SortedSet<RegisteredCommand> cmdSet = evalMap.get(method);
        if (cmdSet == null) {
            return null;
        }
        
        // Split uri into a list of non-empty nodes.
        List<String> pathNodeList = new ArrayList<>();
        String[] pathNodes = uri.split("/");
        for (String pathNode : pathNodes) {
            if (pathNode.length() > 0) {
                pathNodeList.add(pathNode);
            }
        }
        
        // Attempt to match commands in this set in order.
        for (RegisteredCommand cmd : cmdSet) {
            if (cmd.matches(pathNodeList, query, variableMap)) {
                return cmd;
            }
        }
        return null;
    }
305727
public CommandInfo getCommandInfo(String commandName) {
        for (CommandInfo commandInfo : commandInfoList)
            if (commandInfo.cmd_name.toLowerCase().equals(commandName.toLowerCase()))
                return commandInfo;
        return null;
    }