Create the CLI argument parser.
194910
def create_parser():
    """"""
    parser = argparse.ArgumentParser(
        description='Sync a local and a remote folder through SFTP.'
    )

    parser.add_argument(
        "path",
        type=str,
        metavar="local-path",
        help="the path of the local folder",
    )

    parser.add_argument(
        "remote",
        type=str,
        metavar="user[:password]@hostname:remote-path",
        help="the ssh-url ([user[:password]@]hostname:remote-path) of the remote folder. "
             "The hostname can be specified as a ssh_config's hostname too. "
             "Every missing information will be gathered from there",
    )

    parser.add_argument(
        "-k",
        "--key",
        metavar="identity-path",
        action="append",
        help="private key identity path (defaults to ~/.ssh/id_rsa)"
    )

    parser.add_argument(
        "-l",
        "--logging",
        choices=['CRITICAL',
                 'ERROR',
                 'WARNING',
                 'INFO',
                 'DEBUG',
                 'NOTSET'],
        default='ERROR',
        help="set logging level"
    )

    parser.add_argument(
        "-p",
        "--port",
        default=22,
        type=int,
        help="SSH remote port (defaults to 22)"
    )

    parser.add_argument(
        "-f",
        "--fix-symlinks",
        action="store_true",
        help="fix symbolic links on remote side"
    )

    parser.add_argument(
        "-a",
        "--ssh-agent",
        action="store_true",
        help="enable ssh-agent support"
    )

    parser.add_argument(
        "-c",
        "--ssh-config",
        metavar="ssh_config path",
        default="~/.ssh/config",
        type=str,
        help="path to the ssh-configuration file (default to ~/.ssh/config)"
    )

    parser.add_argument(
        "-n",
        "--known-hosts",
        metavar="known_hosts path",
        default="~/.ssh/known_hosts",
        type=str,
        help="path to the openSSH known_hosts file"
    )

    parser.add_argument(
        "-d",
        "--disable-known-hosts",
        action="store_true",
        help="disable known_hosts fingerprint checking (security warning!)"
    )

    parser.add_argument(
        "-e",
        "--exclude-from",
        metavar="exclude-from-file-path",
        type=str,
        help="exclude files matching pattern in exclude-from-file-path"
    )

    parser.add_argument(
        "-t",
        "--do-not-delete",
        action="store_true",
        help="do not delete remote files missing from local folder"
    )

    parser.add_argument(
        "-o",
        "--allow-unknown",
        action="store_true",
        help="allow connection to unknown hosts"
    )

    parser.add_argument(
        "-r",
        "--create-remote-directory",
        action="store_true",
        help="Create remote base directory if missing on remote"
    )

    return parser
710033
def build_argparser():
    """"""
    parser = ArgumentParser('Utility for managing MAR files')
    create_group = parser.add_argument_group("Create a MAR file")
    create_group.add_argument("-c", "--create", metavar="MARFILE", help="create MAR")
    create_group.add_argument("-V", "--productversion", dest="productversion",
                              help="product/version string")
    create_group.add_argument("-H", "--channel", dest="channel",
                              help="channel this MAR file is applicable to")
    create_group.add_argument("files", nargs=REMAINDER,
                              help="files to add to the MAR file")

    extract_group = parser.add_argument_group("Extract a MAR file")
    extract_group.add_argument("-x", "--extract", help="extract MAR", metavar="MARFILE")

    list_group = parser.add_argument_group("Print information on a MAR file")
    list_group.add_argument("-t", "--list", help="print out MAR contents",
                            metavar="MARFILE")
    list_group.add_argument("-T", "--list-detailed", metavar="MARFILE",
                            help="print out MAR contents including signatures")

    verify_group = parser.add_argument_group("Verify a MAR file")
    verify_group.add_argument("-v", "--verify", metavar="MARFILE",
                              help="verify the marfile")

    parser.add_argument("-j", "--bzip2", action="store_const", dest="compression",
                        const="bz2", help="compress/decompress members with BZ2")
    parser.add_argument("-J", "--xz", action="store_const", dest="compression",
                        const="xz", help="compress/decompress archive with XZ")
    parser.add_argument("--auto", action="store_const", dest="compression",
                        const="auto", help="automatically decompress contents")

    parser.add_argument("-k", "--keyfiles", dest="keyfiles", action='append',
                        help="sign/verify with given key(s)")
    parser.add_argument("-C", "--chdir", dest="chdir",
                        help="chdir to this directory before creating or "
                        "extracing; location of marfile isn't affected by "
                        "this option.")
    parser.add_argument("--verbose", dest="loglevel", action="store_const",
                        const=logging.DEBUG, default=logging.WARN,
                        help="increase logging verbosity")
    parser.add_argument('--version', action='version', version='mar version {}'.format(mardor.version_str))

    signing_group = parser.add_argument_group('Sign a MAR file')
    signing_group.add_argument('--hash', help='output hash for signing', choices=('sha1', 'sha384'))
    signing_group.add_argument('--asn1', help='format hash as an ASN1 DigestInfo block',
                               default=False, action='store_true')
    signing_group.add_argument('--add-signature', help='inject signature', nargs=3,
                               metavar=('input', 'output', 'signature'))

    return parser
1231163
def make_parser():
    """"""
    parser = ArgumentParser(
        'wait_for_complete.py',
        usage='%(prog)s [-h] queue_name [options]',
        description=('Wait for a set of batch jobs to complete, and monitor '
                     'them as they run.'),
        epilog=('Jobs can also be monitored, terminated, and otherwise '
                'managed on the AWS website. However this tool will also tag '
                'the instances, and should be run whenever a job is submitted '
                'to AWS.')
    )
    parser.add_argument(
        dest='queue_name',
        help=('The name of the queue to watch and wait for completion. If no '
              'jobs are specified, this will wait until all jobs in the queue '
              'are completed (either SUCCEEDED or FAILED).')
    )
    parser.add_argument(
        '--watch', '-w',
        dest='job_list',
        metavar='JOB_ID',
        nargs='+',
        help=('Specify particular jobs using their job ids, as reported by '
              'the submit command. Many ids may be specified.')
    )
    parser.add_argument(
        '--prefix', '-p',
        dest='job_name_prefix',
        help='Specify a prefix for the name of the jobs to watch and wait for.'
    )
    parser.add_argument(
        '--interval', '-i',
        dest='poll_interval',
        default=10,
        type=int,
        help=('The time interval to wait between job status checks, in '
              'seconds (default: %(default)d seconds).')
    )
    parser.add_argument(
        '--timeout', '-T',
        metavar='TIMEOUT',
        type=int,
        help=('If the logs are not updated for %(metavar)s seconds, '
              'print a warning. If `--kill_on_log_timeout` flag is set, then '
              'the offending jobs will be automatically terminated.')
    )
    parser.add_argument(
        '--kill_on_timeout', '-K',
        action='store_true',
        help='If a log times out, terminate the offending job.'
    )
    parser.add_argument(
        '--stash_log_method', '-l',
        choices=['s3', 'local'],
        metavar='METHOD',
        help=('Select a method from: [%(choices)s] to store the job logs. '
              'If no method is specified, the logs will not be '
              'loaded off of AWS. If \'s3\' is specified, then '
              '`job_name_prefix` must also be given, as this will indicate '
              'where on s3 to store the logs.')
    )
    return parser
334984
def args_parser(self, parser_func: CommandHandler_T) -> CommandHandler_T:
        
        self.cmd.args_parser_func = parser_func
        return parser_func
361411
def _parser():
    """"""
    launcher = 'pip%s-utils' % sys.version_info.major

    parser = argparse.ArgumentParser(
        description='%s.' % __description__,
        epilog='See `%s COMMAND --help` for help '
               'on a specific subcommand.' % launcher,
        prog=launcher)
    parser.add_argument(
        '--version',
        action='version',
        version='%(prog)s ' + __version__)

    subparsers = parser.add_subparsers()

    # dependants
    parser_dependants = subparsers.add_parser(
        'dependants',
        add_help=False,
        help='list dependants of package')
    parser_dependants.add_argument(
        'package',
        metavar='PACKAGE',
        type=_distribution)
    parser_dependants.add_argument(
        '-h', '--help',
        action='help',
        help=argparse.SUPPRESS)
    parser_dependants.set_defaults(
        func=command_dependants)

    # dependents
    parser_dependents = subparsers.add_parser(
        'dependents',
        add_help=False,
        help='list dependents of package')
    parser_dependents.add_argument(
        'package',
        metavar='PACKAGE',
        type=_distribution)
    parser_dependents.add_argument(
        '-i', '--info',
        action='store_true',
        help='show version requirements')
    parser_dependents.add_argument(
        '-r', '--recursive',
        action='store_true',
        help='list dependencies recursively')
    parser_dependents.add_argument(
        '-h', '--help',
        action='help',
        help=argparse.SUPPRESS)
    parser_dependents.set_defaults(
        func=command_dependents)

    # locate
    parser_locate = subparsers.add_parser(
        'locate',
        add_help=False,
        help='identify packages that file belongs to')
    parser_locate.add_argument(
        'file',
        metavar='FILE',
        type=argparse.FileType('r'))
    parser_locate.add_argument(
        '-h', '--help',
        action='help',
        help=argparse.SUPPRESS)
    parser_locate.set_defaults(
        func=command_locate)

    # outdated
    parser_outdated = subparsers.add_parser(
        'outdated',
        add_help=False,
        help='list outdated packages that may be updated')
    parser_outdated.add_argument(
        '-b', '--brief',
        action='store_true',
        help='show package name only')
    group = parser_outdated.add_mutually_exclusive_group()
    group.add_argument(
        '-a', '--all',
        action='store_true',
        help='list all outdated packages')
    group.add_argument(
        '-p', '--pinned',
        action='store_true',
        help='list outdated packages unable to be updated')
    group.add_argument(
        '-U', '--upgrade',
        action='store_true',
        dest='update',
        help='update packages that can be updated'
    )
    parser_outdated.add_argument(
        '-h', '--help',
        action='help',
        help=argparse.SUPPRESS)
    parser_outdated.set_defaults(
        func=command_outdated)

    # parents
    parser_parents = subparsers.add_parser(
        'parents',
        add_help=False,
        help='list packages lacking dependants')
    parser_parents.add_argument(
        '-h', '--help',
        action='help',
        help=argparse.SUPPRESS)
    parser_parents.set_defaults(
        func=command_parents)

    return parser
1034449
def parser():
    """"""
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('-r', '--read-only', action='store_true',
                        help='open notmuch database in read-only mode')
    parser.add_argument('-c', '--config', metavar='FILENAME',
                        action=cargparse.ValidatedStoreAction,
                        validator=cargparse.require_file,
                        help='configuration file')
    parser.add_argument('-n', '--notmuch-config', metavar='FILENAME',
                        default=os.environ.get(
                            'NOTMUCH_CONFIG',
                            os.path.expanduser('~/.notmuch-config')),
                        action=cargparse.ValidatedStoreAction,
                        validator=cargparse.require_file,
                        help='notmuch configuration file')
    parser.add_argument('-C', '--colour-mode', metavar='COLOURS',
                        choices=(1, 16, 256), type=int,
                        help='number of colours to use')
    parser.add_argument('-p', '--mailindex-path', metavar='PATH',
                        action=cargparse.ValidatedStoreAction,
                        validator=cargparse.require_dir,
                        help='path to notmuch index')
    parser.add_argument('-d', '--debug-level', metavar='LEVEL', default='info',
                        choices=('debug', 'info', 'warning', 'error'),
                        help='debug level [default: %(default)s]')
    parser.add_argument('-l', '--logfile', metavar='FILENAME',
                        default='/dev/null',
                        action=cargparse.ValidatedStoreAction,
                        validator=cargparse.optional_file_like,
                        help='log file [default: %(default)s]')
    parser.add_argument('-h', '--help', action='help',
                        help='display this help and exit')
    parser.add_argument('-v', '--version', action='version',
                        version=alot.__version__,
                        help='output version information and exit')
    # We will handle the subcommands in a separate run of argparse as argparse
    # does not support optional subcommands until now.
    parser.add_argument('command', nargs=argparse.REMAINDER,
                        help='possible subcommands are {}'.format(
                            ', '.join(_SUBCOMMANDS)))
    options = parser.parse_args()

    if options.command:
        # We have a command after the initial options so we also parse that.
        # But we just use the parser that is already defined for the internal
        # command that will back this subcommand.
        parser = argparse.ArgumentParser()
        subparsers = parser.add_subparsers(dest='subcommand')
        for subcommand in _SUBCOMMANDS:
            subparsers.add_parser(subcommand,
                                  parents=[COMMANDS['global'][subcommand][1]])
        command = parser.parse_args(options.command)
    else:
        command = None

    return options, command
395130
def _create_parser() -> ArgumentParser:
    
    parser = ArgumentParser(prog=EXECUTABLE_NAME, description=f"{DESCRIPTION} (v{VERSION})")
    parser.add_argument(
        f"-{VERBOSE_SHORT_PARAMETER}", action="count", default=0,
        help="increase the level of log verbosity (add multiple increase further)")
    subparsers = parser.add_subparsers(dest=ACTION_CLI_PARAMETER_ACCESS, help="action")

    unlock_subparser = subparsers.add_parser(Action.UNLOCK.value, help="release a lock")
    unlock_subparser.add_argument(
        f"-{REGEX_KEY_ENABLED_SHORT_PARAMETER}", action="store_true", default=DEFAULT_REGEX_KEY_ENABLED,
        help="whether the key should be treated as a regular expression and to release all matching locks")

    lock_subparser = subparsers.add_parser(Action.LOCK.value, help="acquire a lock")
    lock_and_execute_subparser = subparsers.add_parser(Action.EXECUTE.value, help="call executable whilst holding lock")

    for subparser in (lock_subparser, lock_and_execute_subparser):
        subparser.add_argument(
            f"--{SESSION_TTL_LONG_PARAMETER}", type=float, default=DEFAULT_SESSION_TTL,
            help=f"time to live (ttl) in seconds of the session that will be created to hold the lock. Must be between "
                 f"{MIN_LOCK_TIMEOUT_IN_SECONDS}s and {MAX_LOCK_TIMEOUT_IN_SECONDS}s (inclusive). If set to "
                 f"{NO_EXPIRY_SESSION_TTL_CLI_PARAMETER_VALUE}, the session will not expire")
        subparser.add_argument(
            f"--{NON_BLOCKING_LONG_PARAMETER}", action="store_true",
            default=DEFAULT_NON_BLOCKING, help="do not block if cannot lock straight away")
        subparser.add_argument(
            f"--{TIMEOUT_LONG_PARAMETER}", default=DEFAULT_TIMEOUT, type=float,
            help="give up trying to acquire the key after this many seconds (where 0 is never)")
        subparser.add_argument(
            f"--{METADATA_LONG_PARAMETER}", default=DEFAULT_METADATA, type=str, action=_ParseJsonAction,
            help="additional metadata to add to the lock information (will be converted to JSON)")
        subparser.add_argument(
            f"--{ON_BEFORE_LOCK_LONG_PARAMETER}", default=[], type=str, nargs="+", action="append",
            help="path to executable that is to be called before an attempt is made to acquire a lock, where the lock "
                 "key is passed as the first argument. Any failures of this executable are ignored")
        subparser.add_argument(
            f"--{ON_LOCK_ALREADY_LOCKED_LONG_PARAMETER}", default=[], type=str, nargs="+", action="append",
            help="path to executable that is to be called after an attempt has been made to acquire a lock but failed "
                 "due to the lock already been taken, where the lock key is passed as the first argument. Any failures "
                 "of this executable are ignored")
        subparser.add_argument(
            f"-{LOCK_POLL_INTERVAL_SHORT_PARAMETER}", default=DEFAULT_LOCK_POLL_INTERVAL_GENERATOR(1), type=float,
            help="number of seconds between polls to acquire a locked lock")

    # XXX: probably a better way of iterating subparsers on `subparsers`
    for subparser in [unlock_subparser, lock_subparser, lock_and_execute_subparser]:
        subparser.add_argument(
            KEY_PARAMETER, type=str, help="the lock identifier")

    lock_and_execute_subparser.add_argument(
        EXECUTABLE_PARAMETER, type=str, help="to execute in shell")

    return parser
84063
def _parse_arguments():
    """"""
    parser = argparse.ArgumentParser(description="CMake AST Dumper")
    parser.add_argument("filename", nargs=1, metavar=("FILE"),
                        help="read FILE")
    return parser.parse_args()
444581
def parse_command_line_args():
    """"""
    parser = argparse.ArgumentParser(description='PipApp. {}'.format(DESCRIPTION))
    parser.add_argument(
        '-d', '--dir',
        metavar='DIR',
        help='Root directory where to create new project files and dirs. Default is current directory.'
    )
    parser.add_argument(
        '-v,', '--version',
        action='version',
        version='{} v{}'.format(PROGRAMNAME, VERSION)
    )
    parser.add_argument(
        "project_name",
        metavar='PROJECTNAME',
        help="Name of the generated Project. Has to be a valid Python identifier."
    )
    return parser.parse_args()
1165525
def create_parser(self, prog_name, subcommand):
        
        parser = optparse.OptionParser(
            prog=prog_name,
            usage=self.usage(subcommand),
            version=self.get_version(),
            option_list=self.get_option_list())
        for name, description, option_list in self.get_option_groups():
            group = optparse.OptionGroup(parser, name, description);
            list(map(group.add_option, option_list))
            parser.add_option_group(group)
        return parser
1008278
def cli():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument('api', help="""
        API to call.
        One one of 'article', 'frontpage', 'product', 'image', 'analyze', or
        'discussion'.
    """)
    parser.add_argument('url', help="""
        URL to pass as the 'url' parameter.
    """)
    parser.add_argument('token', help="""
        API key (token).
        Get one at https://www.diffbot.com/.
    """)
    parser.add_argument('-a', '--all', help="""
        Request all fields.
    """, action='store_true')
    parser.add_argument('-f', '--file', help="""
        File to read data from.
        Use '-' to read from STDIN.
    """)
    fields = text = html = None
    _args = parser.parse_args()
    if _args.all:
        fields = '*'
    if _args.file == '-':
        text = sys.stdin.read()
    elif _args.file:
        with open(_args.file, 'rb') as src:
            if os.path.splitext(_args.file)[1] in ('.html', '.htm'):
                html = src.read().decode(ENCODING)
            else:
                text = src.read().decode(ENCODING)
    print(json.dumps((api(_args.api, _args.url, _args.token,
                          html=html or None,
                          text=text or None,
                          fields=fields)),
                     sort_keys=True,
                     indent=2))
599093
def add_parser_arguments():
    """"""
    argparser = parser.get()
    argparser.add_argument('-P', '--profile',
                           action='store',
                           default=None,
                           dest='profile',
                           help='Profile the consumer modules, specifying '
                           'the output directory.')
    argparser.add_argument('-o', '--only',
                           action='store',
                           default=None,
                           dest='consumer',
                           help='Only run the consumer specified')
    argparser.add_argument('-p', '--prepend-path',
                           action='store',
                           default=None,
                           dest='prepend_path',
                           help='Prepend the python path with the value.')
    argparser.add_argument('-q', '--qty',
                           action='store',
                           type=int,
                           default=None,
                           dest='quantity',
                           help='Run the specified quantity of consumer '
                           'processes when used in conjunction with -o')
    argparser.add_argument('--version', action='version',
                           version='%(prog)s {}'.format(__version__))
189419
def make_parser(self, ctx):
        """"""
        parser = OptionParser(ctx)
        parser.allow_interspersed_args = ctx.allow_interspersed_args
        parser.ignore_unknown_options = ctx.ignore_unknown_options
        for param in self.get_params(ctx):
            param.add_to_parser(parser, ctx)
        return parser
1254809
def create_arguments(self, subparsers=False):
        """"""
        ret = []
        if not self._finalized:
            for arg, d in self.unfinished_arguments.items():
                try:
                    not_positional = int(not d.pop('positional', False))
                    short = d.pop('short', None)
                    long_name = d.pop('long', None)
                    if short is None and long_name is None:
                        raise ValueError(
                            "Either a short (-) or a long (--) argument must "
                            "be provided!")
                    if not not_positional:
                        short = arg
                        long_name = None
                        d.pop('dest', None)
                    if short == long_name:
                        long_name = None
                    args = []
                    if short:
                        args.append('-' * not_positional + short)
                    if long_name:
                        args.append('--' * not_positional + long_name)
                    group = d.pop('group', self)
                    if d.get('action') in ['store_true', 'store_false']:
                        d.pop('metavar', None)
                    ret.append(group.add_argument(*args, **d))
                except Exception:
                    print('Error while creating argument %s' % arg)
                    raise
        else:
            raise ValueError('Parser has already been finalized!')
        self._finalized = True
        if subparsers and self._subparsers_action is not None:
            for parser in self._subparsers_action.choices.values():
                parser.create_arguments(True)
        return ret
812609
def create_parser():
    
    parser = argparse.ArgumentParser(prog=pylink.__title__,
                                     description=pylink.__description__,
                                     epilog=pylink.__copyright__)
    parser.add_argument('--version', action='version',
                        version='%(prog)s ' + pylink.__version__)
    parser.add_argument('-v', '--verbose', action='count', default=0,
                        help='increase output verbosity')

    kwargs = {}
    kwargs['title'] = 'command'
    kwargs['description'] = 'specify subcommand to run'
    kwargs['help'] = 'subcommands'
    subparsers = parser.add_subparsers(**kwargs)

    for command in commands():
        kwargs = {}
        kwargs['name'] = command.name
        kwargs['description'] = command.description
        kwargs['help'] = command.help
        subparser = subparsers.add_parser(**kwargs)
        subparser.set_defaults(command=command.run)
        command.add_arguments(subparser)

    return parser
268753
def get_parser():
    """"""

    main_parser = argparse.ArgumentParser(
        formatter_class=argparse.RawTextHelpFormatter)

    main_parser.add_argument(
        '-c', '--config',
        dest='config',
        type=str,
        nargs='?',
        help='Pull the latest repositories from config(s)'
    ).completer = argcomplete.completers.FilesCompleter(
        allowednames=('.yaml', '.yml', '.json'), directories=False
    )

    main_parser.add_argument(
        '-p', '--push',
        dest='do_push',
        action='store_true', default=False,
        help='Push result to target',
    )

    main_parser.add_argument(
        '-d', '--dirmatch',
        dest='dirmatch',
        type=str,
        nargs='?',
        help='Pull only from the directories. Accepts fnmatch(1)'
             'by commands'
    )
    main_parser.add_argument(
        '--log-level',
        default='INFO',
        dest='log_level',
        type=_log_level_string_to_int,
        nargs='?',
        help='Set the logging output level. {0}'.format(_LOG_LEVEL_STRINGS))

    main_parser.add_argument(
        '-e', '--expand-env',
        dest='expand_env',
        default=False,
        action='store_true',
        help='Expand environment variables in configuration file',
    )
    main_parser.add_argument(
        '-f', '--force',
        dest='force',
        default=False,
        action='store_true',
        help='Force cleanup and aggregation on dirty repositories.',
    )

    main_parser.add_argument(
        '-j', '--jobs',
        dest='jobs',
        default=1,
        type=int,
        help='Amount of processes to use when aggregating repos. '
             'This is useful when there are a lot of large repos. '
             'Set `1` or less to disable multiprocessing (default).',
    )

    main_parser.add_argument(
        'command',
        nargs='?',
        default='aggregate',
        help='aggregate (default): run the aggregation process.\n'
             'show-all-prs: show GitHub pull requests in merge sections\n'
             '              such pull requests are indentified as having\n'
             '              a github.com remote and a\n'
             '              refs/pull/NNN/head ref in the merge section.\n'
             'show-closed-prs: show pull requests that are not open anymore.\n'
    )

    return main_parser
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