当前位置: 首页>>代码示例>>Python>>正文


Python click.Argument方法代码示例

本文整理汇总了Python中click.Argument方法的典型用法代码示例。如果您正苦于以下问题:Python click.Argument方法的具体用法?Python click.Argument怎么用?Python click.Argument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在click的用法示例。


在下文中一共展示了click.Argument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_subsampling_params

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def check_subsampling_params(ctx: Context, argument: Argument, value) -> Any:
    subsampling = ctx.params.get('subsampling')

    if not subsampling and value is not None:
        tpl = 'This parameter ({}) only applies to subsampling, to enable it add `--subsampling` to your command'
        app_logger.error(tpl.format(argument.name))
        ctx.abort()

    if argument.name == 'subsampling_log' and subsampling and value is None:
        app_logger.error('''In order to perform subsampling you need to specify whether to log1p input counts or not:
            to do this specify in your command as --subsampling-log [true|false]''')
        ctx.abort()

    defaults = {
        'subsampling_num_pc': 100,
        'subsampling_num_cells': None
    }

    if subsampling and value is None:
        return defaults.get(argument.name, None)

    return value 
开发者ID:Teichlab,项目名称:cellphonedb,代码行数:24,代码来源:method_terminal_commands.py

示例2: format_options

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def format_options(self, ctx, formatter):
        args = []
        opts = []
        for param in self.get_params(ctx):
            rv = param.get_help_record(ctx)
            if rv is not None:
                if isinstance(param, click.Argument):
                    args.append(rv)
                else:
                    opts.append(rv)
        if args:
            with formatter.section('Arguments'):
                formatter.write_dl(args)
        if opts:
            with formatter.section(self.options_metavar):
                formatter.write_dl(opts)

    # overridden to set the limit parameter to always be CLI_HELP_STRING_MAX_LEN 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:20,代码来源:click.py

示例3: command

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def command(name=None, cls=None, **attrs):
    """
    Commands are the basic building block of command line interfaces in
    Click.  A basic command handles command line parsing and might dispatch
    more parsing to commands nested below it.

    :param name: the name of the command to use unless a group overrides it.
    :param context_settings: an optional dictionary with defaults that are
                             passed to the context object.
    :param params: the parameters to register with this command.  This can
                   be either :class:`Option` or :class:`Argument` objects.
    :param help: the help string to use for this command.
    :param epilog: like the help string but it's printed at the end of the
                   help page after everything else.
    :param short_help: the short help to use for this command.  This is
                       shown on the command listing of the parent command.
    :param add_help_option: by default each command registers a ``--help``
                            option.  This can be disabled by this parameter.
    :param options_metavar: The options metavar to display in the usage.
                            Defaults to ``[OPTIONS]``.
    :param args_before_options: Whether or not to display the options
                                        metavar before the arguments.
                                        Defaults to False.
    """
    return click.command(name=name, cls=cls or Command, **attrs) 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:27,代码来源:click.py

示例4: runs_arg

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def runs_arg(fn):
    """### Specify Runs

    You may use one or more `RUN` arguments to indicate which runs
    apply to the command. `RUN` may be a run ID, a run ID prefix, or a
    one-based index corresponding to a run returned by the list
    command.

    Indexes may also be specified in ranges in the form `START:END`
    where `START` is the start index and `END` is the end
    index. Either `START` or `END` may be omitted. If `START` is
    omitted, all runs up to `END` are selected. If `END` id omitted,
    all runs from `START` on are selected. If both `START` and `END`
    are omitted (i.e. the ``:`` char is used by itself) all runs are
    selected.

    """
    click_util.append_params(
        fn, [click.Argument(("runs",), metavar="[RUN...]", nargs=-1)]
    )
    return fn 
开发者ID:guildai,项目名称:guildai,代码行数:23,代码来源:runs_support.py

示例5: import_params

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def import_params(fn):
    click_util.append_params(
        fn,
        [
            runs_support.runs_arg,
            click.Argument(("archive",)),
            click.Option(
                ("-m", "--move"),
                help="Move imported runs rather than copy.",
                is_flag=True,
            ),
            click.Option(
                ("--copy-resources",),
                help="Copy resources for each imported run.",
                is_flag=True,
            ),
            runs_support.all_filters,
            click.Option(
                ("-y", "--yes"), help="Do not prompt before importing.", is_flag=True
            ),
        ],
    )
    return fn 
开发者ID:guildai,项目名称:guildai,代码行数:25,代码来源:runs_import.py

示例6: get_params_convertors_ctx_param_name_from_function

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def get_params_convertors_ctx_param_name_from_function(
    callback: Optional[Callable[..., Any]]
) -> Tuple[List[Union[click.Argument, click.Option]], Dict[str, Any], Optional[str]]:
    params = []
    convertors = {}
    context_param_name = None
    if callback:
        parameters = get_params_from_function(callback)
        for param_name, param in parameters.items():
            if lenient_issubclass(param.annotation, click.Context):
                context_param_name = param_name
                continue
            click_param, convertor = get_click_param(param)
            if convertor:
                convertors[param_name] = convertor
            params.append(click_param)
    return params, convertors, context_param_name 
开发者ID:tiangolo,项目名称:typer,代码行数:19,代码来源:main.py

示例7: choose_database

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def choose_database(ctx: Context, argument: Argument, value: str) -> Optional[str]:
    return DatabaseVersionManager.find_database_for(value) 
开发者ID:Teichlab,项目名称:cellphonedb,代码行数:4,代码来源:choose_database.py

示例8: get_command

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def get_command(self, ctx, name):
        params = [click.Argument(["command"], nargs=-1)]
        plugin = pkg_resources.load_entry_point(
            "pifpaf", "pifpaf.daemons", name)
        params.extend(map(lambda kw: click.Option(**kw), plugin.get_options()))

        def _run_cb(*args, **kwargs):
            return self._run(name, plugin, ctx, *args, **kwargs)

        return click.Command(name=name, callback=_run_cb, params=params) 
开发者ID:jd,项目名称:pifpaf,代码行数:12,代码来源:__main__.py

示例9: argument

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def argument(*param_decls, cls=None, **attrs):
    """
    Arguments are positional parameters to a command.  They generally
    provide fewer features than options but can have infinite ``nargs``
    and are required by default.

    :param param_decls: the parameter declarations for this option or
                        argument.  This is a list of flags or argument
                        names.
    :param type: the type that should be used.  Either a :class:`ParamType`
                 or a Python type.  The later is converted into the former
                 automatically if supported.
    :param required: controls if this is optional or not.
    :param default: the default value if omitted.  This can also be a callable,
                    in which case it's invoked when the default is needed
                    without any arguments.
    :param callback: a callback that should be executed after the parameter
                     was matched.  This is called as ``fn(ctx, param,
                     value)`` and needs to return the value.  Before Click
                     2.0, the signature was ``(ctx, value)``.
    :param nargs: the number of arguments to match.  If not ``1`` the return
                  value is a tuple instead of single value.  The default for
                  nargs is ``1`` (except if the type is a tuple, then it's
                  the arity of the tuple).
    :param metavar: how the value is represented in the help page.
    :param expose_value: if this is `True` then the value is passed onwards
                         to the command callback and stored on the context,
                         otherwise it's skipped.
    :param is_eager: eager values are processed before non eager ones.  This
                     should not be set for arguments or it will inverse the
                     order of processing.
    :param envvar: a string or list of strings that are environment variables
                   that should be checked.
    :param help: the help string.
    :param hidden: hide this option from help outputs.
                   Default is True, unless help is given.
    """
    return click.argument(*param_decls, cls=cls or Argument, **attrs) 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:40,代码来源:click.py

示例10: _format_argument

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def _format_argument(arg):
    """Format the output of a `click.Argument`."""
    yield '.. option:: {}'.format(arg.human_readable_name)
    yield ''
    yield _indent('{} argument{}'.format(
        'Required' if arg.required else 'Optional',
        '(s)' if arg.nargs != 1 else '')) 
开发者ID:click-contrib,项目名称:sphinx-click,代码行数:9,代码来源:ext.py

示例11: _format_arguments

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def _format_arguments(ctx):
    """Format all `click.Argument` for a `click.Command`."""
    params = [x for x in ctx.command.params if isinstance(x, click.Argument)]

    for param in params:
        for line in _format_argument(param):
            yield line
        yield '' 
开发者ID:click-contrib,项目名称:sphinx-click,代码行数:10,代码来源:ext.py

示例12: _format_envvar

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def _format_envvar(param):
    """Format the envvars of a `click.Option` or `click.Argument`."""
    yield '.. envvar:: {}'.format(param.envvar)
    yield '   :noindex:'
    yield ''
    if isinstance(param, click.Argument):
        param_ref = param.human_readable_name
    else:
        # if a user has defined an opt with multiple "aliases", always use the
        # first. For example, if '--foo' or '-f' are possible, use '--foo'.
        param_ref = param.opts[0]

    yield _indent('Provide a default for :option:`{}`'.format(param_ref)) 
开发者ID:click-contrib,项目名称:sphinx-click,代码行数:15,代码来源:ext.py

示例13: _format_argument

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def _format_argument(arg):
    """Format the output of a `click.Argument`."""
    yield '.. option:: {}'.format(arg.human_readable_name)
    yield ''
    yield _indent('{} argument{}'.format(
        'Required' if arg.required else 'Optional', '(s)'
        if arg.nargs != 1 else '')) 
开发者ID:mirnylab,项目名称:cooler,代码行数:9,代码来源:make_cli_rst.py

示例14: delete_params

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def delete_params(fn):
    click_util.append_params(
        fn,
        [
            click.Argument(
                ("packages",), metavar="PACKAGE...", nargs=-1, required=True
            ),
            click.Option(
                ("-y", "--yes",),
                help="Do not prompt before uninstalling.",
                is_flag=True,
            ),
        ],
    )
    return fn 
开发者ID:guildai,项目名称:guildai,代码行数:17,代码来源:packages_delete.py

示例15: remote_arg

# 需要导入模块: import click [as 别名]
# 或者: from click import Argument [as 别名]
def remote_arg(fn):
    """`REMOTE` is the name of a configured remote. Use ``guild remotes``
    to list available remotes.

    For information on configuring remotes, see ``guild remotes
    --help``.

    """
    click_util.append_params(fn, [click.Argument(("remote",))])
    return fn 
开发者ID:guildai,项目名称:guildai,代码行数:12,代码来源:remote_support.py


注:本文中的click.Argument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。