How to use the click.pass_context function in click

To help you get started, we’ve selected a few click examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dask / dask-ec2 / dask_ec2 / cli / main.py View on Github external
@click.pass_context
@click.option("--keyname", required=True, help="Keyname on EC2 console")
@click.option("--keypair",
              required=True,
              type=click.Path(exists=True),
              help="Path to the keypair that matches the keyname")
@click.option("--name",
              required=False,
              default="dask-ec2-cluster",
              help="Tag name on EC2")
@click.option("--tags",
              required=False,
              default=None,
              help="Additional EC2 tags.  Comma separated K:V pairs: K1:V1,K2:V2")
@click.option("--region-name",
              default="us-east-1",
              show_default=True,
github aiidateam / aiida-core / aiida / cmdline / commands / cmd_calculation.py View on Github external
@click.pass_context
@decorators.deprecated_command("This command is deprecated. Use 'verdi calcjob outputls' instead.")
def calculation_outputls(ctx, calculation, path, color):
    """
    Show the list of files in the directory with relative PATH in the raw input folder of the CALCULATION.

    If PATH is not specified, the base path of the retrieved folder will be used.
    Content can only be showm after the daemon has retrieved the remote files.
    """
    ctx.invoke(verdi_calcjob.get_command(ctx, 'outputls'), calcjob=calculation, path=path, color=color)
github jrabbit / pyborg-1up / pyborg / pyborg_entrypoint.py View on Github external
@click.pass_context
@click.option(
    "--cred-file",
    default='pyborg_mastodon_clientcred.secret',
    type=click.Path(exists=True),
)
def mastodon_login(ctx, cred_file, username, password):
    mastodon = Mastodon(client_id=cred_file, api_base_url=ctx.obj['base_url'])
    mastodon.log_in(username, password, to_file=os.path.join(ctx.obj['secret_folder'], 'pyborg_mastodon_usercred.secret'))
github danielfrg / datasciencebox / datasciencebox / cli / open.py View on Github external
@click.pass_context
def open_marathon(ctx):
    project = ctx.obj['project']
    url = 'http://%s:8080' % project.cluster.head.ip
    webbrowser.open(url, new=2)
github dask / dask-gke / dask_gke / cli / main.py View on Github external
@click.pass_context
@click.argument('cluster', required=True)
def info(ctx, cluster):
    context = get_context_from_settings(cluster)
    print_info(cluster, context)
github oracle / oci-cli / services / dts / src / oci_cli_transfer_job / generated / transferjob_cli.py View on Github external
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'dts', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'dts', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'dts', 'class': 'TransferJob'})
@cli_util.wrap_exceptions
def update_transfer_job(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, id, lifecycle_state, display_name, device_type, freeform_tags, defined_tags, if_match):

    if isinstance(id, six.string_types) and len(id.strip()) == 0:
        raise click.UsageError('Parameter --id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match

    details = {}
github aiidateam / aiida-core / aiida / cmdline / commands / cmd_work.py View on Github external
@click.pass_context
@decorators.deprecated_command("This command is deprecated. Use 'verdi process kill' instead.")
def work_kill(ctx, workflows):
    """Kill work workflows."""
    ctx.invoke(verdi_process.process_kill, processes=workflows)
github oracle / oci-cli / services / core / src / oci_cli_virtual_network / virtualnetwork_cli_extended.py View on Github external
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def change_network_security_group_compartment_extended(ctx, **kwargs):
    if 'nsg_id' in kwargs:
        kwargs = swap_nsg_id_value(kwargs)
    ctx.invoke(virtualnetwork_cli.change_network_security_group_compartment, **kwargs)
github eamonnfaherty / aws-statement-maker / statement_maker.py View on Github external
@click.group()
@click.pass_context
def main(ctx):
    pass