本文整理汇总了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
示例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
示例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)
示例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