Read in arguments for the current subcommand. These are added to the
        cmd line without '--' appended. Any others are redirected as standard
        options with the double hyphen prefixed.
320859
def arguments(self, args=None):
        '''
        
        '''
        # permits deleting elements rather than using slices
        args = args and list(args) or []

        # match against all known/supported subcmds
        if self.subcmd == 'apply':
            # apply subcommand requires a manifest file to execute
            self.subcmd_args = [args[0]]
            del args[0]

        if self.subcmd == 'agent':
            # no arguments are required
            args.extend([
                'test'
            ])

        # finally do this after subcmd has been matched for all remaining args
        self.args = args
422417
function command(cmd, args, info) {
  var map = info.commands || Constants.MAP
    , def = map[cmd]
    , sub;

  // support command exec handlers that
  // encapsulate the definition
  if(def && def.definition !== undefined) {
    def = def.definition;
  }

  // top-level command
  if(def === undefined) {
    throw new UnknownCommand(cmd);
  }

  // made it this far, check subcommands
  // for commands that require a subcommand
  if(Constants.SUBCOMMAND[cmd] && args.length > 0) {
    sub = Constants.SUBCOMMAND[cmd][args[0]];
    if(!sub) {
      if(cmd === Constants.MAP.client.name) {
        throw ClientSyntax;
      }
      throw UnknownSubcommand;
    }
    // mutate the sub response to include
    // the subcommand as a primary command
    // and the remaining arguments, callers
    // can use this to locate a subcommand
    // execution method
    sub = {def: sub, cmd: args[0], args: args.slice(1)};
  }

  return {cmd: cmd, args: args, def: def, sub: sub};
}
769660
def get_arg_name(self, param):
        
        if self.current_command in self.cmdtab:
            for arg in self.cmdtab[self.current_command].arguments:

                for name in self.cmdtab[self.current_command].arguments[arg].options_list:
                    if name == param:
                        return arg
        return None
1078514
def handle_cmd_options():
    '''
    
    '''
    parser = OptionParser()
    parser.add_option("-s", "--silent", action="store_true", dest="silent",
                      help="print any warnings", default=False)
    (options, args) = parser.parse_args()
    return options, args
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;
}
38912
def _add_two_argument_command(self, command, arg1, arg2):
        """"""
        self.lines.append("{} {} {}".format(command, arg1, arg2))
121404
def read_element_using_argtuple(self, argtuple):
		

		# doesn't support DELIMITED, only dict-based formats
		if self.format == FMT_DELIMITED:
			return None

		node = self.cfg_dict
		for key in argtuple:
			node = node[key]
		return node
644604
def cmd2args(cmd):
    
    if isinstance(cmd, str):
        return cmd if win32 else shlex.split(cmd)
    return cmd
947900
def parse_cmd(cmd, flags)
      if cmd.flags?
        args = Raw.arguments_to(cmd.flags.short, flags)
        if args.nil? || args.empty?
          args = Raw.arguments_to(cmd.flags.long, flags)
        end
      else
        args = Raw.arguments_to(cmd.index.to_s, flags)
      end
      unless cmd.type.to_s =~ /stdin/
        return nil if args.nil?
      end
      case cmd.type
      when :stdin
        args = STDIN.gets.strip
      when :stdin_stream
        args = STDIN
      when :stdin_string
        args = STDIN.gets.strip
      when :stdin_strings
        args = []
        while arg = STDIN.gets
          next if arg.nil?
          arg = arg.strip
          args << arg
        end
        args
      when :stdin_integer
        args = STDIN.gets.strip.to_i
      when :stdin_integers
        args = []
        while arg = STDIN.gets
          next if arg.nil?
          arg = arg.strip
          parse = arg.to_i
          if parse.to_s == arg
            args << parse
          end
        end
        args
      when :stdin_bool
        args = STDIN.gets.strip.downcase == "true"
      when :single, :string
        args = args.first
      when :strings, :multi
        if cmd.delimiter?
          if args.count > 1
            args = args.first.split(cmd.delimiter)
          else
            args = args.map { |arg| arg.split(cmd.delimiter) }.flatten
          end
        end
        args
      when :integer
        args = args.first.to_i
      when :integers
        if cmd.delimiter?
          if args.count > 1
            args = args.join
            args = args.select { |arg| arg if arg.include?(cmd.delimiter) }
            args = args.map { |arg| arg.split(cmd.delimiter) }.flatten
          else
            args = args.map { |arg| arg.split(cmd.delimiter) }.flatten
          end
        end
        args = args.map(&:to_i)
      when :bool, :bools
        if cmd.delimiter?
          if args.count > 1
            args = args.join
            args = args.select { |arg| arg if arg.include?(cmd.delimiter) }
            args = args.map { |arg| arg.split(cmd.delimiter) }.flatten
          else
            args = args.map { |arg| arg.split(cmd.delimiter) }.flatten
          end
        end
        args = args.map { |arg| arg == "true" }
      end
    rescue => e# this is dangerous
      puts e
      nil
    end
1220472
def show_command(parameter):
    
    section = "cli"
    if "." in parameter:
        section, parameter = parameter.split(".", 1)

    value = lookup_option(parameter, section=section)

    if value is None:
        safeprint("{} not set".format(parameter))
    else:
        safeprint("{} = {}".format(parameter, value))
651515
def parse_options(args) # :nodoc:
      option_parser_class = self.class.const_get("#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser")
      OptionParsingResult.new.tap { |parsing_result|
        parsing_result.arguments = args
        parsing_result = @global_option_parser.parse!(parsing_result)
        option_parser_class.new(@accepts).parse!(parsing_result, options[:argument_handling_strategy])
      }
    end
309
def main(args=None):
    """"""
    parser = _parser()

    # Python 2 will error 'too few arguments' if no subcommand is supplied.
    # No such error occurs in Python 3, which makes it feasible to check
    # whether a subcommand was provided (displaying a help message if not).
    # argparse internals vary significantly over the major versions, so it's
    # much easier to just override the args passed to it. In this case, print
    # the usage message if there are no args.
    if args is None and len(sys.argv) <= 1:
        sys.argv.append('--help')

    options = parser.parse_args(args)

    # pass options to subcommand
    options.func(options)

    return 0
951059
def print_help(self, file=None):
        
        output = file or self.stderr
        CustomStderrOptionParser.print_help(self, output)
        output.write("\nCommands:\n")
        for command_def in self.command_definitions.values():
            command_def.opt_parser.print_help(output)
            output.write("\n")
182065
def parse_subcommands(parser, subcommands, argv):
    

    subparsers = parser.add_subparsers(dest='subparser_name')

    # add help sub-command
    parser_help = subparsers.add_parser(
        'help', help='Detailed help for actions using `help <action>`')
    parser_help.add_argument('action', nargs=1)

    # add all other subcommands
    modules = [
        name for _, name, _ in pkgutil.iter_modules(subcommands.__path__)]
    commands = [m for m in modules if m in argv]

    actions = {}

    # `commands` will contain the module corresponding to a single
    # subcommand if provided; otherwise, generate top-level help
    # message from all submodules in `modules`.
    for name in commands or modules:
        # set up subcommand help text. The first line of the dosctring
        # in the module is displayed as the help text in the
        # script-level help message (`script -h`). The entire
        # docstring is displayed in the help message for the
        # individual subcommand ((`script action -h`))
        # if no individual subcommand is specified (run_action[False]),
        # a full list of docstrings is displayed
        try:
            imp = '{}.{}'.format(subcommands.__name__, name)
            mod = importlib.import_module(imp)
        except Exception as e:
            log.error(e)
            continue

        subparser = subparsers.add_parser(
            name,
            help=mod.__doc__.lstrip().split('\n', 1)[0],
            description=mod.__doc__,
            formatter_class=argparse.RawDescriptionHelpFormatter)

        mod.build_parser(subparser)

        # see global subcommands/__init__.py
        subcommands.build_parser(subparser)

        actions[name] = mod.action

    return parser, actions
1263042
def cmdHELP(self, params):
        
        if params:
            cmd = params[0].upper()
            if self.COMMANDS.has_key(cmd):
                method = self.COMMANDS[cmd]
                doc = method.__doc__.split("\n")
                docp = doc[0].strip()
                docl = '\n'.join( [l.strip() for l in doc[2:]] )
                if not docl.strip():  # If there isn't anything here, use line 1
                    docl = doc[1].strip()
                self.writeline(
                    "%s %s\n\n%s" % (
                        cmd,
                        docp,
                        docl,
                    )
                )
                return
            else:
                self.writeline("Command '%s' not known" % cmd)
        else:
            self.writeline("Help on built in commands\n")
        keys = self.COMMANDS.keys()
        keys.sort()
        for cmd in keys:
            method = self.COMMANDS[cmd]
            if getattr(method, 'hidden', False):
                continue
            if method.__doc__ == None:
                self.writeline("no help for command %s" % method)
                return
            doc = method.__doc__.split("\n")
            docp = doc[0].strip()
            docs = doc[1].strip()
            if len(docp) > 0:
                docps = "%s - %s" % (docp, docs, )
            else:
                docps = "- %s" % (docs, )
            self.writeline(
                "%s %s" % (
                    cmd,
                    docps,
                )
            )
927778
def __printCommandSyntax(self, command):
        
        commandHelp = self.completion[command]
        if commandHelp != None and len(commandHelp) > 2:
            commandValues = commandHelp[2]
            #commandDefault = commandHelp[3]
            displayHelp = [self._color(self.COLOR_WHITE, command)]
            if commandValues != None:
                valuesIsEnum = len(commandHelp) >= 6
                if '+' in command or command.upper() in ['ATS0']:
                    displayHelp.append(self._color(self.COLOR_WHITE, '='))
                displayHelp.append(('|' if valuesIsEnum else ',').join([value[0] for value in commandValues]))
            sys.stdout.write('\r Syntax: {0}\n'.format(self._color(self.COLOR_WHITE, ''.join(displayHelp))))
            sys.stdout.flush()
            self._refreshInputPrompt(len(self.inputBuffer))
1036663
private String[] augmentCommand(String[] args, Class<? extends Command> cmd,
			boolean acceptsInputFile) {
		OptionGroup<ID> options;
		try {
			if (acceptsInputFile) {
				options = OptionIntrospector.introspect(cmd, InputFileCommand.class);
			} else {
				options = OptionIntrospector.introspect(cmd);
			}
		} catch (IntrospectionException e) {
			//should never happen
			throw new RuntimeException(e);
		}
		
		ShellContext sc = ShellContext.current();
		for (Option<ID> o : options.getOptions()) {
			if (o.getLongName().equals("style")) {
				args = ArrayUtils.add(args, "--style");
				args = ArrayUtils.add(args, sc.getStyle());
			} else if (o.getLongName().equals("locale")) {
				args = ArrayUtils.add(args, "--locale");
				args = ArrayUtils.add(args, sc.getLocale());
			} else if (o.getLongName().equals("format")) {
				args = ArrayUtils.add(args, "--format");
				args = ArrayUtils.add(args, sc.getFormat());
			} else if (o.getLongName().equals("input") &&
					sc.getInputFile() != null && !sc.getInputFile().isEmpty()) {
				args = ArrayUtils.add(args, "--input");
				args = ArrayUtils.add(args, sc.getInputFile());
			}
		}
		
		return args;
	}