Parses all the command line arguments using argparse and returns them.
352270
def parse_arguments():
    
    parser = argparse.ArgumentParser()

    parser.add_argument('file', metavar="FILE", nargs='+',
                        help='file to be made executable')
    parser.add_argument("-p", "--python", metavar="VERSION",
                        help="python version (2 or 3)")
    parser.add_argument('-v', '--version', action='version',
                        version='%(prog)s ' + __version__, help='show version')
    parser.add_argument('-r', '--recursive', action='store_true',
                        help='recursively iterate the directories')

    args = parser.parse_args()
    return args
334984
def args_parser(self, parser_func: CommandHandler_T) -> CommandHandler_T:
        
        self.cmd.args_parser_func = parser_func
        return parser_func
769216
def _parse_args(cls):
        
        cls.parser = argparse.ArgumentParser()
        cls.parser.add_argument(
            "symbol", help="Symbol for horizontal line", nargs="*")
        cls.parser.add_argument(
            "--color", "-c", help="Color of the line", default=None, nargs=1)
        cls.parser.add_argument(
            "--version", "-v", action="version", version="0.13")

        return cls.parser
1025511
def _parse_args(arg):
    '''
    
    '''
    yaml_args = salt.utils.args.yamlify_arg(arg)

    if yaml_args is None:
        return []
    elif not isinstance(yaml_args, list):
        return [yaml_args]
    else:
        return yaml_args
1261735
def parse_args( self, args = None, values = None ):
        '''
        
        '''
        q = multiproc.Queue()
        p = multiproc.Process(target=self._parse_args, args=(q, args, values))
        p.start()
        ret = q.get()
        p.join()
        return ret
781493
def _parse_args():
    
    parser = argparse.ArgumentParser(description='rain - a new sort of automated builder.')
    
    parser.add_argument('action', help='what shall we do?', default='build', nargs='?',
                        choices=['build',
                                 'ls',
                                 'keep'] + removal_cmds)

    parser.add_argument('-c', '--count', type=int, default=1,
                        help='a count of items on which to operate. [default: %(default)s]')

    parser.add_argument('--keep', type=int, default=-1,
                        help='how many builds should we keep around? [default: %(default)s]')

    parser.add_argument('-v', '--verbose', action='count', default=0, help='Be more verbose. (can be repeated)')

    parser.add_argument('--version', default=False, action='store_true',
                        help='print version number and exit. [default: %(default)s]')

    return parser.parse_args()
36213
def parse_arguments(argv):
    
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    base_parser = argparse.ArgumentParser(add_help=False)

    parser.add_argument('-V', '--version', action='version',
                        version='taxit v' + version,
                        help='Print the version number and exit')

    parser.add_argument('-v', '--verbose',
                        action='count', dest='verbosity', default=1,
                        help='Increase verbosity of screen output (eg, -v is verbose, '
                        '-vv more so)')
    parser.add_argument('-q', '--quiet',
                        action='store_const', dest='verbosity', const=0,
                        help='Suppress output')

    ##########################
    # Setup all sub-commands #
    ##########################

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

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

    actions = {}

    for name, mod in subcommands.itermodules(
            os.path.split(subcommands.__file__)[0]):
        # 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`)).
        subparser = subparsers.add_parser(
            name,
            prog='taxit {}'.format(name),
            help=mod.__doc__.lstrip().split('\n', 1)[0],
            description=mod.__doc__,
            formatter_class=RawDescriptionHelpFormatter,
            parents=[base_parser])

        mod.build_parser(subparser)
        actions[name] = mod.action

    # Determine we have called ourself (e.g. "help <action>")
    # Set arguments to display help if parameter is set
    #           *or*
    # Set arguments to perform an action with any specified options.
    arguments = parser.parse_args(argv)
    # Determine which action is in play.
    action = arguments.subparser_name

    # Support help <action> by simply having this function call itself and
    # translate the arguments into something that argparse can work with.
    if action == 'help':
        return parse_arguments([str(arguments.action[0]), '-h'])

    return actions[action], arguments
1175269
def parse_args(self, args=None, namespace=None):
        
        if not namespace:  # use the new Namespace class for handling _config
            namespace = Namespace(self)
        namespace = super(ArgumentParser, self).parse_args(args, namespace)
        if len(self._reparse_args['pos']) > 0 or \
           len(self._reparse_args['opt']) > 0 or \
           len(self._reparse_args['sub']) > 0:
            args = self._reset_args()
            namespace = super(ArgumentParser, self).parse_args(args, namespace)
        # process "-hh..." here, after having parsed the arguments
        help_level = getattr(namespace, "help", 0)
        if help_level > 0:
            self.print_help()
            self.print_extended_help(help_level)
            self.exit()
        return namespace
182194
def parse_args():
  ''' 
  '''
  parser = optparse.OptionParser()

  parser.add_option("-v", "--verbose", action="store_true")

  mode_group = optparse.OptionGroup(parser, "Program Mode")
  mode_group.add_option("-u", "--update-status", action="store_const",
                        dest="mode", const="update_status")
  mode_group.add_option("-g", "--generate-cfg", action="store_const",
                        dest="mode", const="generate_cfg")
  parser.add_option_group(mode_group)
  parser.set_defaults(mode="update_status")

  general_options = optparse.OptionGroup(parser, "CM API Configuration")
  general_options.add_option("-H", "--host", metavar="HOST",
                             help="CM API hostname")
  general_options.add_option("-p", "--port", help="CM API port", default=None)
  general_options.add_option("-P", "--passfile", metavar="FILE",
                             help="File containing CM API username and password, "
                                  "colon-delimited on a single line.  E.g. "
                                  "\"user:pass\"")
  general_options.add_option("--use-tls", action="store_true",
                             help="Use TLS", default=False)
  parser.add_option_group(general_options)

  polling_options = optparse.OptionGroup(parser, "Status Update Options")
  polling_options.add_option("-c", "--cmd-file", metavar="FILE",
                             help="Path to the file that Nagios checks for "
                                  "external command requests.")
  polling_options.add_option("-n", "--use-send-nsca", action="store_true",
                             default=False,
                             help="Use send_nsca to report status via a nsca "
                                  "daemon. When using this option, the "
                                  "send_nsca program must be available and the "
                                  "nsca daemon host and port must be provided."
                                  "Default is false.")
  polling_options.add_option("--send-nsca-path", metavar="PATH",
                             default="/usr/sbin/send_nsca",
                             help="Path to send_nsca, default is "
                                  "/usr/sbin/send_nsca")
  polling_options.add_option("--nsca-host", metavar="HOST",
                             default="localhost",
                             help="When using send_nsca, the hostname of NSCA "
                                  "server, default is localhost.")
  polling_options.add_option("--nsca-port", metavar="PORT", default=None,
                             help="When using send_nsca, the port on which the "
                                  "server is running, default is 5667.")
  polling_options.add_option("--send-nsca-config", metavar="FILE", default=None,
                             help="Config file passed to send_nsca -c. Default"
                                  " is to not specify the config parameter.")
  parser.add_option_group(polling_options)


  generate_options = optparse.OptionGroup(parser, "Generate Config Options")
  generate_options.add_option("--cfg-dir", metavar="DIR", default=getcwd(),
                              help="Directory for generated Nagios cfg files.")
  parser.add_option_group(generate_options)

  (options, args) = parser.parse_args()

  ''' Parse the 'passfile' - it must contain the username and password,
      colon-delimited on a single line. E.g.:
      $ cat ~/protected/cm_pass
      admin:admin
  '''
  required = ["host", "passfile"]

  if options.mode == "update_status":
    if not options.use_send_nsca:
      required.append("cmd_file")

  for required_opt in required:
    if getattr(options, required_opt) is None:
      parser.error("Please specify the required argument: --%s" %
                   (required_opt.replace('_','-'),))

  return (options, args)
620502
def create_argparser():
    
    parser = argparse.ArgumentParser()
    arg_defaults = {
        "daemon": False,
        "loop": False,
        "listpresets": False,
        "config": None,
        "debug": False,
        "sleeptime": 300,
        "version": False,
        "verbose_count": 0
    }

    # add generic client options to the CLI:
    parser.add_argument("-c", "--config", dest="config",
                        help="config file", default=arg_defaults["config"])
    parser.add_argument("--list-presets", dest="listpresets",
                        help="list all available presets",
                        action="store_true", default=arg_defaults["listpresets"])
    parser.add_argument("-d", "--daemon", dest="daemon",
                        help="go into daemon mode (implies --loop)",
                        action="store_true", default=arg_defaults["daemon"])
    parser.add_argument("--debug", dest="debug",
                        help="increase logging level to DEBUG (DEPRECATED, please use -vvv)",
                        action="store_true", default=arg_defaults["debug"])
    parser.add_argument("--loop", dest="loop",
                        help="loop forever (default is to update once)",
                        action="store_true", default=arg_defaults["loop"])
    parser.add_argument("--sleeptime", dest="sleeptime",
                        help="how long to sleep between checks in seconds",
                        default=arg_defaults["sleeptime"])
    parser.add_argument("--version", dest="version",
                        help="show version and exit",
                        action="store_true", default=arg_defaults["version"])
    parser.add_argument("-v", "--verbose", dest="verbose_count",
                        action="count", default=arg_defaults["verbose_count"],
                        help="increases log verbosity for each occurrence")

    return parser, arg_defaults
203543
def parse_args():
    """"""
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        description='Diagnose script for checking the current system.')
    choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network']
    for choice in choices:
        parser.add_argument('--' + choice, default=1, type=int,
                            help='Diagnose {}.'.format(choice))
    parser.add_argument('--region', default='', type=str,
                        help="Additional sites in which region(s) to test. \
                        Specify 'cn' for example to test mirror sites in China.")
    parser.add_argument('--timeout', default=10, type=int,
                        help="Connection test timeout threshold, 0 to disable.")
    args = parser.parse_args()
    return args
1337937
def load_args(self, args, clargs):
        
        # Parse All Arguments
        args = self.parser.parse_args(args=clargs, namespace=args)

        # Print the help information if no subcommand is given
        # subcommand is required for operation
        if args.subcommand is None:
            self.parser.print_help()
            args = None

        return args
788464
def getargs():
    
    parser = argparse.ArgumentParser(description='\
    Select paths from a directory tree.')
    parser.add_argument("-a", "--hidden", action="store_false",
                        help="Show all hidden paths too.")
    parser.add_argument("-r", "--relative", action="store_true",
                        help="Output relative paths.")
    parser.add_argument("path", type=chkpath, nargs='?',
                        default=".", help="A valid path.")
    return parser.parse_args()
930272
def parse_args():
    
    parser = argparse.ArgumentParser(description = 'Decrypt AEADs',
                                     add_help = True,
                                     formatter_class = argparse.ArgumentDefaultsHelpFormatter,
                                     )
    parser.add_argument('-v', '--verbose',
                        dest='verbose',
                        action='store_true', default=False,
                        help='Enable verbose operation',
                        )
    parser.add_argument('--debug',
                        dest='debug',
                        action='store_true', default=False,
                        help='Enable debug operation',
                        )
    parser.add_argument('--format',
                        dest='format',
                        default='raw',
                        help='Select output format (aead, raw or yubikey-csv)',
                        )
    parser.add_argument('--output-dir',
                        dest='output_dir',
                        help='Output dir basename (for --format aead)',
                        metavar='DIR',
                        )
    parser.add_argument('--print-filename',
                        dest='print_filename',
                        action='store_true', default=False,
                        help='Prefix each row with the AEAD filename',
                        )
    parser.add_argument('--key-handle',
                        dest='key_handle',
                        help='Key handle used when generating the AEADs.',
                        metavar='HANDLE',
                        )
    parser.add_argument('--key-handle-out',
                        dest='key_handle_out',
                        help='Key handle used when generating *new* AEADs (with --format aead).',
                        metavar='HANDLE',
                        )
    parser.add_argument('--aes-key',
                        dest='aes_key',
                        required=True,
                        help='AES key used when generating the AEADs.',
                        metavar='HEXSTR',
                        )
    parser.add_argument('--aes-key-out',
                        dest='aes_key_out',
                        required=False,
                        help='AES key used when generating *new* AEADs (with --format aead).',
                        metavar='HEXSTR',
                        )
    parser.add_argument('--start-public-id',
                        dest='start_id',
                        required=False, default=None,
                        help='The first public id to decrypt',
                        metavar='INT-OR-MODHEX',
                        )
    parser.add_argument('--stop-public-id',
                        dest='stop_id',
                        required=False, default=None,
                        help='The last public id to decrypt',
                        metavar='INT-OR-MODHEX',
                        )
    parser.add_argument('--fail-fast',
                        dest='fail_fast',
                        action='store_true', default=False,
                        help='Terminate on the first AEAD failure, rather than keep going.',
                        )
    parser.add_argument('paths',
                        nargs='+',
                        help='Files and/or directories to process.',
                        metavar='FILE-OR-DIR'
                        )
    args = parser.parse_args()
    # argument fixups
    args.format = args.format.lower()
    args.aes_key = args.aes_key.decode('hex')
    if args.key_handle:
        args.key_handle = pyhsm.util.key_handle_to_int(args.key_handle)
    if args.start_id is not None:
        try:
            n = int(args.start_id)
        except ValueError:
            hexstr = pyhsm.yubikey.modhex_decode(args.start_id)
            n = int(hexstr, 16)
        args.start_id = n
    if args.stop_id is not None:
        try:
            n = int(args.stop_id)
        except ValueError:
            hexstr = pyhsm.yubikey.modhex_decode(args.stop_id)
            n = int(hexstr, 16)
        args.stop_id = n
    # some checks
    if args.format == 'aead':
        if not args.output_dir:
            sys.stderr.write("error: --output-dir is required when using --format aead.\n")
            return False
        if not os.path.isdir(args.output_dir):
            sys.stderr.write("error: Output directory '%s' not found\n" % (args.output_dir))
            return False
        if not args.aes_key_out:
            sys.stderr.write("error: --aes-key-out is required when using --format aead.\n")
            return False
        if not args.key_handle_out:
            sys.stderr.write("error: --key-handle-out is required when using --format aead.\n")
            return False
        # argument fixups
        args.aes_key_out = args.aes_key_out.decode('hex')
        args.key_handle_out_orig = args.key_handle_out # save to use in AEAD output paths
        args.key_handle_out = pyhsm.util.key_handle_to_int(args.key_handle_out)
    return args
197205
def parse_config_args(args)
      result = {}
      args.scan(/--?([a-z\-\_]+)\s([\d]+)\s?/).each do |arg|
        result[arg.first] = arg.last
      end
      {'raw' => args, 'parsed' => result}
    end
1194816
def parse_arguments():
    """"""
    parser = create_parser()
    args = parser.parse_args()
    if not args.role_requirements_old_commit:
        args.role_requirements_old_commit = args.role_requirements
    if not args.rpc_product_old_commit:
        args.rpc_product_old_commit = args.rpc_product
    return args
475897
def _parse_args(args, cls):
    
    
    d = _create_djset(args, cls)
    
    key_value_pair = args.get('<key>=<value>')
    key = args.get('<key>')
    func = None
    if args.get('add') and key_value_pair:
        fargs = tuple(args.get('<key>=<value>').split('='))
        if fargs[1]:
            func = d.set
    elif args.get('remove') and key:
        func = d.remove
        fargs = (args.get('<key>'),)
    kwargs = {'glob': args.get('--global')}
    if func:
        return func, fargs, kwargs
    else:
        return None, None, None