Creates a parser with arguments specific to sending HTTP requests
    to multiple REST APIs.

    Returns:
        {ArgumentParser}: Base parser with default HTTP args
181330
def base_multinode_parser():
    
    base_parser = ArgumentParser(add_help=False)

    base_parser.add_argument(
        'urls',
        type=str,
        nargs='+',
        help="The URLs of the validator's REST APIs of interest, separated by"
        " commas or spaces. (no default)")
    base_parser.add_argument(
        '--users',
        type=str,
        action='append',
        metavar='USERNAME[:PASSWORD]',
        help='Specify the users to authorize requests, in the same order as '
        'the URLs, separate by commas. Passing empty strings between commas '
        'is supported.')

    return base_parser
594672
def create_parser(name, description=None):
    
    prog = _gen_prog_name(name)
    parser = argparse.ArgumentParser(prog=prog, description=description)
    parser.add_argument('config_uri', help="Configuration INI file.")
    parser.add_argument('--config-name',
                        action='store',
                        default='main',
                        help="Supply a section name in the configuration")
    return parser
334984
def args_parser(self, parser_func: CommandHandler_T) -> CommandHandler_T:
        
        self.cmd.args_parser_func = parser_func
        return parser_func
1318377
def start_rest_api(host, port, connection, timeout, registry,
                   client_max_size=None):
    
    loop = asyncio.get_event_loop()
    connection.open()
    app = web.Application(loop=loop, client_max_size=client_max_size)
    app.on_cleanup.append(lambda app: connection.close())

    # Add routes to the web app
    LOGGER.info('Creating handlers for validator at %s', connection.url)

    handler = RouteHandler(loop, connection, timeout, registry)

    app.router.add_post('/batches', handler.submit_batches)
    app.router.add_get('/batch_statuses', handler.list_statuses)
    app.router.add_post('/batch_statuses', handler.list_statuses)

    app.router.add_get('/state', handler.list_state)
    app.router.add_get('/state/{address}', handler.fetch_state)

    app.router.add_get('/blocks', handler.list_blocks)
    app.router.add_get('/blocks/{block_id}', handler.fetch_block)

    app.router.add_get('/batches', handler.list_batches)
    app.router.add_get('/batches/{batch_id}', handler.fetch_batch)

    app.router.add_get('/transactions', handler.list_transactions)
    app.router.add_get(
        '/transactions/{transaction_id}',
        handler.fetch_transaction)

    app.router.add_get('/receipts', handler.list_receipts)
    app.router.add_post('/receipts', handler.list_receipts)

    app.router.add_get('/peers', handler.fetch_peers)
    app.router.add_get('/status', handler.fetch_status)

    subscriber_handler = StateDeltaSubscriberHandler(connection)
    app.router.add_get('/subscriptions', subscriber_handler.subscriptions)
    app.on_shutdown.append(lambda app: subscriber_handler.on_shutdown())

    # Start app
    LOGGER.info('Starting REST API on %s:%s', host, port)

    web.run_app(
        app,
        host=host,
        port=port,
        access_log=LOGGER,
        access_log_format='%r: %s status, %b size, in %Tf s')
946513
def make_parser(defaults=None):
    
    if defaults is None:
        defaults = DEFAULTS

    ctypes = API.list_types()
    ctypes_s = ", ".join(ctypes)
    type_help = "Select type of %s config files from " + \
        ctypes_s + " [Automatically detected by file ext]"

    mts = API.MERGE_STRATEGIES
    mts_s = ", ".join(mts)
    mt_help = "Select strategy to merge multiple configs from " + \
        mts_s + " [%(merge)s]" % defaults

    parser = argparse.ArgumentParser(usage=USAGE)
    parser.set_defaults(**defaults)

    parser.add_argument("inputs", type=str, nargs='*', help="Input files")
    parser.add_argument("--version", action="version",
                        version="%%(prog)s %s" % anyconfig.globals.VERSION)

    lpog = parser.add_argument_group("List specific options")
    lpog.add_argument("-L", "--list", action="store_true",
                      help="List supported config types")

    spog = parser.add_argument_group("Schema specific options")
    spog.add_argument("--validate", action="store_true",
                      help="Only validate input files and do not output. "
                           "You must specify schema file with -S/--schema "
                           "option.")
    spog.add_argument("--gen-schema", action="store_true",
                      help="Generate JSON schema for givne config file[s] "
                           "and output it instead of (merged) configuration.")

    gspog = parser.add_argument_group("Query/Get/set options")
    gspog.add_argument("-Q", "--query", help=_QUERY_HELP)
    gspog.add_argument("--get", help=_GET_HELP)
    gspog.add_argument("--set", help=_SET_HELP)

    parser.add_argument("-o", "--output", help="Output file path")
    parser.add_argument("-I", "--itype", choices=ctypes, metavar="ITYPE",
                        help=(type_help % "Input"))
    parser.add_argument("-O", "--otype", choices=ctypes, metavar="OTYPE",
                        help=(type_help % "Output"))
    parser.add_argument("-M", "--merge", choices=mts, metavar="MERGE",
                        help=mt_help)
    parser.add_argument("-A", "--args", help="Argument configs to override")
    parser.add_argument("--atype", choices=ctypes, metavar="ATYPE",
                        help=_ATYPE_HELP_FMT % ctypes_s)

    cpog = parser.add_argument_group("Common options")
    cpog.add_argument("-x", "--ignore-missing", action="store_true",
                      help="Ignore missing input files")
    cpog.add_argument("-T", "--template", action="store_true",
                      help="Enable template config support")
    cpog.add_argument("-E", "--env", action="store_true",
                      help="Load configuration defaults from "
                           "environment values")
    cpog.add_argument("-S", "--schema", help="Specify Schema file[s] path")
    cpog.add_argument("-e", "--extra-opts",
                      help="Extra options given to the API call, "
                           "--extra-options indent:2 (specify the "
                           "indent for pretty-printing of JSON outputs) "
                           "for example")
    cpog.add_argument("-v", "--verbose", action="count", dest="loglevel",
                      help="Verbose mode; -v or -vv (more verbose)")
    return parser
63075
def generate_base_provider_parser():
    """"""
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument('action', help='specify the action to take', default='list',
                        choices=['create', 'list', 'update', 'delete'])
    parser.add_argument(
        'domain', help='specify the domain, supports subdomains as well')
    parser.add_argument('type', help='specify the entry type', default='TXT',
                        choices=['A', 'AAAA', 'CNAME', 'MX', 'NS', 'SOA', 'TXT', 'SRV', 'LOC'])

    parser.add_argument('--name', help='specify the record name')
    parser.add_argument('--content', help='specify the record content')
    parser.add_argument('--ttl', type=int,
                        help='specify the record time-to-live')
    parser.add_argument('--priority', help='specify the record priority')
    parser.add_argument(
        '--identifier', help='specify the record for update or delete actions')
    parser.add_argument('--log_level', help='specify the log level', default='ERROR',
                        choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'NOTSET'])
    parser.add_argument('--output',
                        help=('specify the type of output: by default a formatted table (TABLE), '
                              'a formatted table without header (TABLE-NO-HEADER), '
                              'a JSON string (JSON) or no output (QUIET)'),
                        default='TABLE', choices=['TABLE', 'TABLE-NO-HEADER', 'JSON', 'QUIET'])
    return parser
674324
def make_parser():
    
    parser = ArgumentParser(
        description='Start an IRC bot instance from the command line.',
        formatter_class=ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument(
        '-v', '--version',
        action='version',
        version='{0} v{1}'.format(NAME, VERSION)
    )
    parser.add_argument(
        '-s', '--server',
        metavar='HOST',
        required=True,
        help='the host to connect to'
    )
    parser.add_argument(
        '-p', '--port',
        metavar='PORT',
        type=int,
        default=6667,
        help='the port the server is listening on'
    )
    parser.add_argument(
        '-n', '--nick',
        metavar='NAME',
        required=True,
        help="the bot's nickname"
    )
    parser.add_argument(
        '-N', '--name',
        metavar='NAME',
        default=NAME,
        help="the bot's real name"
    )
    parser.add_argument(
        '-c', '--channels',
        metavar='CHAN',
        nargs='*',
        help='join this channel upon connection'
    )
    parser.add_argument(
        '-l', '--log',
        metavar='LEVEL',
        default='INFO',
        help='minimal level for displayed logging messages'
    )
    parser.add_argument(
        '-S', '--ssl',
        action='store_true',
        help='connect to the server using SSL'
    )
    return parser
963030
def _default_parser(self):
        
        parser = ArgumentParser(prog='enaml-native')

        #: Build commands by name
        cmds = {c.title: c for c in self.commands}

        #: Build parser, prepare commands
        subparsers = parser.add_subparsers()
        for c in self.commands:
            p = subparsers.add_parser(c.title, help=c.help)
            c.parser = p
            for (flags, kwargs) in c.args:
                p.add_argument(*flags.split(), **kwargs)
            p.set_defaults(cmd=c)
            c.ctx = self.ctx
            c.cmds = cmds
            c.cli = self

        return parser
566603
def genargs() -> ArgumentParser:
    
    parser = ArgumentParser()
    parser.add_argument("infile", help="Input JSG specification")
    parser.add_argument("-o", "--outfile", help="Output python file (Default: {infile}.py)")
    parser.add_argument("-e", "--evaluate", help="Evaluate resulting python file as a test", action="store_true")
    parser.add_argument("-v", "--verbose", help="Verbose output", action="store_true")
    return parser
369747
def get_cli_parser(func, skip_first=0, parser=None):
    
    help_msg, func_args = _get_func_args(func)
    if not parser:
        parser = ArgumentParser(description=help_msg)

    for i, arg in enumerate(func_args):
        arg_name, arg_type, arg_default, arg_required, arg_help = arg
        if i < skip_first:
            continue

        if arg_default is not _empty:
            parser.add_argument(
                arg_name, type=arg_type, default=arg_default,
                required=arg_required, help=arg_help
            )
        else:
            parser.add_argument(
                arg_name, type=arg_type, required=arg_required, help=arg_help
            )
    return parser
548907
def _api_handler(self, *args, **kwargs):
        
        keyword_arguments = {}
        keyword_arguments.update(self.keywords)
        keyword_arguments.update(kwargs)
        return api_handler(*args, **keyword_arguments)
575709
def get_argparser(parser=None):
        """"""
        parser = parser or argparse.ArgumentParser()
        parser.add_argument("--host", default="0.0.0.0", help="Host listen address")
        parser.add_argument("--port", "-p", default=9050, help="Listen port", type=int)
        parser.add_argument(
            "--debug",
            "-d",
            default=False,
            action="store_true",
            help="Enable debug mode",
        )
        parser.add_argument(
            "--log-level",
            "-l",
            default="INFO",
            help="Log Level, empty string to disable.",
        )
        parser.add_argument(
            "--twisted",
            default=False,
            action="store_true",
            help="Use twisted to server requests.",
        )
        parser.add_argument(
            "--gunicorn",
            default=False,
            action="store_true",
            help="Use gunicorn to server requests.",
        )
        parser.add_argument(
            "--threads", default=None, help="Number of threads to use.", type=int
        )
        parser.add_argument("--disable-embedded-logging",
                            default=False,
                            action="store_true",
                            help="Disable embedded logging configuration")
        return parser
167782
def parse_arguments():
    
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-c", dest="count", default=0, type=int,
        help="Number of pings to send"
    )
    parser.add_argument(
        "-i", dest="interval", default=1, type=float, help="Ping interval"
    )
    parser.add_argument(
        "-d", dest="timings", default=False, action="store_true",
        help="Show timings for the entire connection"
    )
    parser.add_argument(
        'destination', nargs='+', help='Destination host or URL'
    )
    args = parser.parse_args()
    return args, args.destination
717719
def _build_send_args(self, **kwargs):
        
        out = {}
        out.update(self._default_send_args)
        out.update(kwargs)
        return out
16766
def define_baseargs(self, parser):
        '''
        
        '''
        parser.add_argument('--name', default=sys.argv[0],
            help='Name to identify this instance')
        parser.add_argument('--log-level', default=None,
            help='Logging level as picked from the logging module')
        parser.add_argument('--log-format', default=None,
            # TODO add more formats
            choices=("json", "pretty",),
            help=("Force the format of the logs. By default, if the "
                  "command is from a terminal, print colorful logs. "
                  "Otherwise print json."),
        )
        parser.add_argument('--log-file', default=None,
            help='Writes logs to log file if specified, default: %(default)s',
        )
        parser.add_argument('--quiet', default=False, action="store_true",
            help='if true, does not print logs to stderr, default: %(default)s',
        )
        parser.add_argument('--metric-grouping-interval', default=None, type=int,
            help='To group metrics based on time interval ex:10 i.e;(10 sec)',
        )
        parser.add_argument('--debug', default=False, action="store_true",
            help='To run the code in debug mode',
        )
830637
def parse_args(args):
    
    parser = argparse.ArgumentParser(
        description='Starts the REST API application and connects to a '
        'specified validator.')

    parser.add_argument('-B', '--bind',
                        help='identify host and port for API to run on \
                        default: http://localhost:8008)',
                        action='append')
    parser.add_argument('-C', '--connect',
                        help='specify URL to connect to a running validator')
    parser.add_argument('-t', '--timeout',
                        help='set time (in seconds) to wait for validator \
                        response')
    parser.add_argument('--client-max-size',
                        type=int,
                        help='the max size (in bytes) of a request body')
    parser.add_argument('-v', '--verbose',
                        action='count',
                        default=0,
                        help='enable more verbose output to stderr')
    parser.add_argument('--opentsdb-url',
                        help='specify host and port for Open TSDB database \
                        used for metrics')
    parser.add_argument('--opentsdb-db',
                        help='specify name of database for storing metrics')

    try:
        version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version
    except pkg_resources.DistributionNotFound:
        version = 'UNKNOWN'

    parser.add_argument(
        '-V', '--version',
        action='version',
        version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}')
        .format(version),
        help='display version information')

    return parser.parse_args(args)
18997
def arg_default(*args, **kwargs):
    
    parser = argparse.ArgumentParser()
    parser.add_argument(*args, **kwargs)
    args = vars(parser.parse_args([]))
    _, default = args.popitem()
    return default