當前位置: 首頁>>代碼示例>>Python>>正文


Python click.version_option方法代碼示例

本文整理匯總了Python中click.version_option方法的典型用法代碼示例。如果您正苦於以下問題:Python click.version_option方法的具體用法?Python click.version_option怎麽用?Python click.version_option使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在click的用法示例。


在下文中一共展示了click.version_option方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_params

# 需要導入模塊: import click [as 別名]
# 或者: from click import version_option [as 別名]
def get_params(self, name):
        def show_help(ctx, param, value):
            if value and not ctx.resilient_parsing:
                click.echo(ctx.get_help(), color=ctx.color)
                ctx.exit()

        return [
            click.version_option(version=self.version, message="%(version)s"),
            click.option(
                "-h",
                "--help",
                is_flag=True,
                is_eager=True,
                expose_value=False,
                callback=show_help,
                help="Show this message and exit.",
            ),
        ] + self.common_options 
開發者ID:GaretJax,項目名稱:django-click,代碼行數:20,代碼來源:adapter.py

示例2: create_dagster_cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import version_option [as 別名]
def create_dagster_cli():
    commands = {
        'api': api_cli,
        'pipeline': pipeline_cli,
        'run': run_cli,
        'instance': instance_cli,
        'schedule': schedule_cli,
        'asset': asset_cli,
    }

    @click.group(commands=commands)
    @click.version_option(version=__version__)
    def group():
        'CLI tools for working with dagster.'

    # add the path for the cwd so imports in dynamically loaded code work correctly
    sys.path.append(os.getcwd())
    return group 
開發者ID:dagster-io,項目名稱:dagster,代碼行數:20,代碼來源:__init__.py

示例3: version_option

# 需要導入模塊: import click [as 別名]
# 或者: from click import version_option [as 別名]
def version_option(f):
    """
    Largely a custom clone of click.version_option -- almost identical, but
    prints our special output.
    """

    def callback(ctx, param, value):
        # copied from click.decorators.version_option
        # no idea what resilient_parsing means, but...
        if not value or ctx.resilient_parsing:
            return

        print_version()
        ctx.exit(0)

    return click.option(
        "--version",
        is_flag=True,
        expose_value=False,
        is_eager=True,
        callback=callback,
        hidden=True,
    )(f) 
開發者ID:globus,項目名稱:globus-cli,代碼行數:25,代碼來源:version_option.py

示例4: common_options

# 需要導入模塊: import click [as 別名]
# 或者: from click import version_option [as 別名]
def common_options(f):
    """Add common options to commands via a decorator."""
    f = click.version_option()(f)
    f = click.option('-v', '--verbose', count=True,
                     help=('Verbosity, how detailed should the output be. This is *stackable*, so `-vv`'
                           ' is more verbose than `-v`. For the most verbose option try `-vvvv` or `-vvvvv`.'))(f)
    f = click.option('-n', '--nocolor', is_flag=True,
                     help='No color - if this is set then the output will be without ANSI color codes.')(f)
    f = click.option('--dialect', default=None, help='The dialect of SQL to lint (default=ansi)')(f)
    f = click.option('--templater', default=None, help='The templater to use (default=jinja)')(f)
    f = click.option('--rules', default=None,
                     # short_help='Specify a particular rule, or comma seperated rules, to check',
                     help=('Narrow the search to only specific rules. For example '
                           'specifying `--rules L001` will only search for rule `L001` (Unnessesary '
                           'trailing whitespace). Multiple rules can be specified with commas e.g. '
                           '`--rules L001,L002` will specify only looking for violations of rule '
                           '`L001` and rule `L002`.'))(f)
    f = click.option('--exclude-rules', default=None,
                     # short_help='Specify a particular rule, or comma seperated rules to exclude',
                     help=('Exclude specific rules. For example '
                           'specifying `--exclude-rules L001` will remove rule `L001` (Unnessesary '
                           'trailing whitespace) from the set of considered rules. This could either '
                           'be the whitelist, or the general set if there is no specific whitelist. '
                           'Multiple rules can be specified with commas e.g. '
                           '`--exclude-rules L001,L002` will exclude violations of rule '
                           '`L001` and rule `L002`.'))(f)
    f = click.option('--ignore', default=None,
                     help=("Ignore particular families of errors so that they don't cause a failed "
                           "run. For example `--ignore parsing` would mean that any parsing errors "
                           "are ignored and don't influence the success or fail of a run. Multiple "
                           "options are possible if comma seperated e.g. `--ignore parsing,templating`."))(f)
    return f 
開發者ID:alanmcruickshank,項目名稱:sqlfluff,代碼行數:34,代碼來源:commands.py


注:本文中的click.version_option方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。