Manually guess some known command names, where we can
        do a better job than the automatic parsing.
559287
def _guess_cmd_name(self, cmd):
        

        # zcat to bowtie
        if cmd[0] == 'zcat' and 'bowtie' in cmd:
            return 'bowtie'
        # samtools
        if cmd[0] == 'samtools':
            return ' '.join(cmd[0:2])
        # java (eg. picard)
        if cmd[0] == 'java':
            jars = [s for s in cmd if '.jar' in s]
            return os.path.basename(jars[0].replace('.jar', ''))
        return cmd[0]
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)
417449
function getCommandNames(cmds) {
  var commands = _.map(cmds, '_name');
  commands = commands.concat.apply(commands, _.map(cmds, '_aliases'));
  commands.sort();
  return commands;
}
714539
def cmdline(argv, flags):
    """"""
    rules = dict([(flag, {'flags': ["--%s" % flag]}) for flag in flags])
    return parse(argv, rules)
51042
def match(command, options, args):
    """"""
    build = ""
    possible = commands
    for l in command:
        build += l
        possible = filter(lambda w: w.startswith(build), possible)
    
    if len(possible) == 0:
        raise ArgError("Command invalid: %s" % command)
    
    if len(possible) > 1:
        raise ArgError("Ambiguous command: %s" % command)

    command = possible.pop()

    if not num_args[command](len(args)):
        raise ArgError("Bad number of args for command %s" % command)

    return command
600697
def list_commands(self, ctx):
        """"""
        commands = super(LegitGroup, self).list_commands(ctx)
        return [cmd for cmd in order_manually(commands)]
665179
def subparsers(self):
        """"""
        try:
            return self.__subparsers
        except AttributeError:
            parent = super(ArgumentParser, self)
            self.__subparsers = parent.add_subparsers(title="drill down")
            self.__subparsers.metavar = "COMMAND"
            return self.__subparsers
77139
def find_match_command(self, rule):
        """"""

        command_string = rule['command']
        command_list = command_string.split()

        self.logdebug('comparing "%s" to "%s"\n' %
                      (command_list, self.original_command_list))
        if rule.get('allow_trailing_args'):
            self.logdebug('allow_trailing_args is true - comparing initial '
                          'list.\n')
            # Verify the initial arguments are all the same
            if (self.original_command_list[:len(command_list)] ==
                    command_list):
                self.logdebug('initial list is same\n')
                return {'command': self.original_command_list}
            else:
                self.logdebug('initial list is not same\n')

        elif rule.get('pcre_match'):
            if re.search(command_string, self.original_command_string):
                return {'command': self.original_command_list}

        elif command_list == self.original_command_list:
            return {'command': command_list}
1115550
def _rudimentary_get_command(self, args):
        
        nouns = []
        command_names = self.commands_loader.command_table.keys()
        for arg in args:
            if arg and arg[0] != '-':
                nouns.append(arg)
            else:
                break

        def _find_args(args):
            search = ' '.join(args).lower()
            return next((x for x in command_names if x.startswith(search)), False)

        # since the command name may be immediately followed by a positional arg, strip those off
        while nouns and not _find_args(nouns):
            del nouns[-1]

        # ensure the command string is case-insensitive
        for i in range(len(nouns)):
            args[i] = args[i].lower()

        return ' '.join(nouns)
764241
function getMatchObject(input, commands) {
  var len = input.context.length;
  var trimmed = String(input.context).replace(/^\s+/g, '');
  var prefix = new Array((len - trimmed.length) + 1).join(' ');
  var match;
  var suffix;
  commands.forEach(function (cmd) {
    var nextChar = trimmed.substr(cmd.length, 1);
    if (trimmed.substr(0, cmd.length) === cmd && String(cmd).trim() !== '' && nextChar === ' ') {
      match = cmd;
      suffix = trimmed.substr(cmd.length);
      prefix += trimmed.substr(0, cmd.length);
    }
  });

  var matchObject = (match) ?
    _.find(this.parent.commands, {_name: String(match).trim()}) :
    undefined;

  if (!matchObject) {
    this.parent.commands.forEach(function (cmd) {
      if ((cmd._aliases || []).indexOf(String(match).trim()) > -1) {
        matchObject = cmd;
      }
      return;
    });
  }

  if (!matchObject) {
    matchObject = _.find(this.parent.commands, {_catch: true});
    if (matchObject) {
      suffix = input.context;
    }
  }

  if (!matchObject) {
    prefix = input.context;
    suffix = '';
  }

  if (matchObject) {
    input.match = matchObject;
    input.prefix += prefix;
    input.context = suffix;
  }
  return input;
}
1021236
def parse(self, commands):
        

        # Get rid of dummy objects that represented deleted objects in
        # the last parsing round.
        to_delete = []
        for id_, val in self._objects.items():
            if val == JUST_DELETED:
                to_delete.append(id_)
        for id_ in to_delete:
            self._objects.pop(id_)

        for command in commands:
            self._parse(command)
1231803
def get_ns_commands(self, cmd_name):
        
        namespace, command = _split_ns_command(cmd_name)
        if not namespace:
            # Name space not given, look for the commands
            spaces = self.__find_command_ns(command)
            if not spaces:
                # Unknown command
                raise ValueError("Unknown command {0}".format(command))
            else:
                # Return a sorted list of tuples
                return sorted((namespace, command) for namespace in spaces)

        # Single match
        return [(namespace, command)]
688057
def get_corrected_commands(self, command):
        
        new_commands = self.get_new_command(command)
        if not isinstance(new_commands, list):
            new_commands = (new_commands,)
        for n, new_command in enumerate(new_commands):
            yield CorrectedCommand(script=new_command,
                                   side_effect=self.side_effect,
                                   priority=(n + 1) * self.priority)
335599
function parseCommandLine(args) {

    var parsed_cmds = [];

    if (args.length <= 2) {
        parsed_cmds.push(defaultCommand());
    } else {

        var cli = args.slice(2);

        var pos = 0;
        var cmd;

        cli.forEach(function(element, index, array) {

            //replace alias name with real name.
            if (element.indexOf('--') === -1 && element.indexOf('-') === 0) {
                cli[index] = alias_map[element];
            }

            //parse command and args
            if (cli[index].indexOf('--') === -1) {
                cmd.args.push(cli[index]);
            } else {

                if (keys[cli[index]] == "undefined") {
                    throw new Error("not support command:" + cli[index]);
                };

                pos = index;
                cmd = commands[cli[index]];
                if (typeof cmd.args == 'undefined') {
                    cmd.args = [];
                };
                parsed_cmds.push(cmd);
            }
        });
    };

    return parsed_cmds;
}
942310
def help(opts, bot, _):
    
    command = opts['<command>']
    if command is None:
        return bot.help_text()

    if command not in bot.commands:
        return "%r is not a known command" % command

    return bot.commands[command].__doc__
986081
def commands(cls):
        """"""
        cmds = [cmd[4:] for cmd in dir(cls) if cmd.startswith('cmd_')]
        return cmds
379695
def get_corrected_commands(command):
    
    corrected_commands = (
        corrected for rule in get_rules()
        if rule.is_match(command)
        for corrected in rule.get_corrected_commands(command))
    return organize_commands(corrected_commands)