當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。