Python click.version_option() Examples
The following are 4
code examples of click.version_option().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
click
, or try the search function
.
Example #1
Source File: adapter.py From django-click with MIT License | 8 votes |
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
Example #2
Source File: __init__.py From dagster with Apache License 2.0 | 6 votes |
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
Example #3
Source File: version_option.py From globus-cli with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: commands.py From sqlfluff with MIT License | 5 votes |
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