Alias for more readable command construction
430835
def f(field: str, kwargs: Dict[str, Any],
      default: Optional[Any] = None) -> str:
    
    if default is not None:
        return str(kwargs.get(field, default))
    return str(kwargs[field])
780430
function commandFactory(combos, cmd)
{
  var command;

  // if no combos provided
  // consider it as a single command run
  if (!cmd)
  {
    cmd = combos;
    combos = [{}];
  }

  command = partial(iterate, combos, cmd);
  command.commandDescription = partial(commandDescription, cmd);
  return command;
}
23546
def command(self, *args, **kwargs):
        
        aliases = kwargs.pop('aliases', None)
        decorator = super(ProfilingCLI, self).command(*args, **kwargs)
        if aliases is None:
            return decorator
        def _decorator(f):
            cmd = decorator(f)
            for alias in aliases:
                self.command_name_aliases[alias] = cmd.name
            return cmd
        return _decorator
305494
private CharSequence documentCommand(String command) {
		MethodTarget methodTarget = commandRegistry.listCommands().get(command);
		if (methodTarget == null) {
			throw new IllegalArgumentException("Unknown command '" + command + "'");
		}

		AttributedStringBuilder result = new AttributedStringBuilder().append("\n\n");
		List<ParameterDescription> parameterDescriptions = getParameterDescriptions(methodTarget);

		// NAME
		documentCommandName(result, command, methodTarget.getHelp());

		// SYNOPSYS
		documentSynopsys(result, command, parameterDescriptions);

		// OPTIONS
		documentOptions(result, parameterDescriptions);

		// ALSO KNOWN AS
		documentAliases(result, command, methodTarget);

		// AVAILABILITY
		documentAvailability(result, methodTarget);

		result.append("\n");
		return result;
	}
355468
function encodeCommand(command) {
  const topInfo = Buffer.from(`*${command.length}\r\n`)
  const parts = command.map(adjustCommandArgument)
                  .map(x => Buffer.from(`\$${x.length}\r\n${x}\r\n`))

  parts.unshift(topInfo)
  return Buffer.concat(parts)
}
1193738
def get_command(self, ctx, name):
        """"""
        env = ctx.ensure_object(environment.Environment)
        env.load()

        # Do alias lookup (only available for root commands)
        if len(self.path) == 0:
            name = env.resolve_alias(name)

        new_path = list(self.path)
        new_path.append(name)
        module = env.get_command(*new_path)
        if isinstance(module, types.ModuleType):
            return CommandLoader(*new_path, help=module.__doc__ or '')
        else:
            return module
1068769
def clean_library_commands
      aliases = @commands_hash.select {|k,v| @commands.include?(k) }.
        map {|k,v| v[:alias] }.compact
      @commands -= aliases
      @commands.uniq!
    end
1332587
def alias_list(self, args: argparse.Namespace) -> None:
        """"""
        if args.name:
            for cur_name in utils.remove_duplicates(args.name):
                if cur_name in self.aliases:
                    self.poutput("alias create {} {}".format(cur_name, self.aliases[cur_name]))
                else:
                    self.perror("Alias '{}' not found".format(cur_name), traceback_war=False)
        else:
            sorted_aliases = utils.alphabetical_sort(self.aliases)
            for cur_alias in sorted_aliases:
                self.poutput("alias create {} {}".format(cur_alias, self.aliases[cur_alias]))
917068
def extend(self, cli_api, command_prefix="", sub_command="", **kwargs):
        """"""
        if sub_command and command_prefix:
            raise ValueError('It is not currently supported to provide both a command_prefix and sub_command')

        if sub_command:
            self.commands[sub_command] = cli_api
        else:
            for name, command in cli_api.commands.items():
                self.commands["{}{}".format(command_prefix, name)] = command
1306049
def _expand(self, line: str) -> str:
        """"""

        # expand aliases
        # make a copy of aliases so we can edit it
        tmp_aliases = list(self.aliases.keys())
        keep_expanding = bool(tmp_aliases)
        while keep_expanding:
            for cur_alias in tmp_aliases:
                keep_expanding = False
                # apply our regex to line
                match = self._command_pattern.search(line)
                if match:
                    # we got a match, extract the command
                    command = match.group(1)
                    if command and command == cur_alias:
                        # rebuild line with the expanded alias
                        line = self.aliases[cur_alias] + match.group(2) + line[match.end(2):]
                        tmp_aliases.remove(cur_alias)
                        keep_expanding = bool(tmp_aliases)
                        break

        # expand shortcuts
        for (shortcut, expansion) in self.shortcuts:
            if line.startswith(shortcut):
                # If the next character after the shortcut isn't a space, then insert one
                shortcut_len = len(shortcut)
                if len(line) == shortcut_len or line[shortcut_len] != ' ':
                    expansion += ' '

                # Expand the shortcut
                line = line.replace(shortcut, expansion, 1)
                break
        return line
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;
}
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
}
1013409
def _normalize_cmd_args(cmd):
    
    if isinstance(cmd, basestring):
        # check for standard or anonymous named pipes
        if cmd.find(" | ") > 0 or cmd.find(">(") or cmd.find("<("):
            return "set -o pipefail; " + cmd, True, find_bash()
        else:
            return cmd, True, None
    else:
        return [str(x) for x in cmd], False, None
986081
def commands(cls):
        """"""
        cmds = [cmd[4:] for cmd in dir(cls) if cmd.startswith('cmd_')]
        return cmds
965199
private function getCommandAliasesText($command)
    {
        $text = '';
        $aliases = $command->getAliases();

        if ($aliases) {
            $text = '['.implode('|', $aliases).'] ';
        }

        return $text;
    }
749861
function restoreAlias(cmd){
  var cmds;
  if(aliases[cmd]){
    cmds = aliases[cmd].trim().split(/\s+/);
  }
  return cmds;
}
873848
def _manage_commands():
    
    for name, (command, *aliases) in COMMANDS.items():
        COMMAND_MAPPER[name] = command
        for alias in aliases:
            COMMAND_MAPPER[alias] = command
        COMMAND_ALIASES[name] = aliases