How to use the click.pass_obj 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 Grunny / zap-cli / zapcli / commands / policies.py View on Github external
@click.pass_obj
def set_policy_threshold(zap_helper, policy_ids, threshold):
    """Set the alert threshold for policies."""
    if not policy_ids:
        policy_ids = _get_all_policy_ids(zap_helper)

    with zap_error_handler():
        zap_helper.set_policy_alert_threshold(policy_ids, threshold)

    console.info('Set alert threshold to {0}.'.format(threshold))
github zhmcclient / python-zhmcclient / zhmccli / _cmd_hba.py View on Github external
@click.pass_obj
def hba_delete(cmd_ctx, cpc, partition, hba):
    """
    Delete an HBA.

    In addition to the command-specific options shown in this help text, the
    general options (see 'zhmc --help') can also be specified right after the
    'zhmc' command name.
    """
    cmd_ctx.execute_cmd(lambda: cmd_hba_delete(cmd_ctx, cpc, partition, hba))
github eventbrite / bay / bay / plugins / build.py View on Github external
@click.pass_obj
def build(app, containers, host, cache, recursive, verbose):
    """
    Build container images, along with its build dependencies.
    """

    app.run_hooks(PluginHook.INIT_GROUP_BUILD)

    # `bay build` is equivalent to `bay build profile`
    if not containers:
        containers = [ContainerType.Profile]

    logfile_name = app.config.get_path('bay', 'build_log_path', app)
    containers_to_pull = []
    containers_to_build = []
    pulled_containers = set()
    failed_pulls = set()
github TokenMarketNet / sto / sto / cli / main.py View on Github external
@click.pass_obj
def issue(config: BoardCommmadConfiguration, symbol, name, url, amount, transfer_restriction):
    """Issue out a new security token.

    * Creates a new share series

    * Allocates all new shares to the management account

    * Sets the share transfer restriction mode
    """

    logger = config.logger

    assert is_ethereum_network(config.network) # Nothing else implemented yet

    from sto.ethereum.issuance import deploy_token_contracts
    from sto.ethereum.txservice import EthereumStoredTXService
github neo4j-drivers / boltkit / boltkit / server / console.py View on Github external
    @click.pass_obj
    def browser(self, machine):
        """ Start the Neo4j browser.

        A machine name may optionally be passed, which denotes the server to
        which the browser should be tied. If no machine name is given, 'a' is
        assumed.
        """

        def f(m):
            click.echo("Opening web browser for machine {!r} at "
                       "«{}»".format(m.spec.fq_name, m.spec.http_uri))
            open_browser(m.spec.http_uri)

        if not self._for_each_machine(machine, f):
            raise RuntimeError("Machine {!r} not found".format(machine))
github pybel / pybel / src / pybel / cli.py View on Github external
@click.pass_obj
def compile(
    manager, path, allow_naked_names, disallow_nested, disallow_unqualified_translocations,
    no_identifier_validation, no_citation_clearing, required_annotations, upgrade_urls, skip_tqdm,
):
    """Compile a BEL script to a graph."""
    logger.debug('using connection: %s', manager.engine.url)

    click.secho('Compilation', fg='red', bold=True)
    if skip_tqdm:
        click.echo('```')
    graph = from_bel_script(
        path,
        manager=manager,
        use_tqdm=(not skip_tqdm),
        disallow_nested=disallow_nested,
        allow_naked_names=allow_naked_names,
github birlorg / bitwarden-cli / python / bitwarden / main.py View on Github external
@click.pass_obj
def fetch_name(cli, name, pwonly, decrypt, fulldecrypt):
	"""fetch by name.

    This will be relatively slow, as it has to decrypt every single name
    to compare before it finds the right one.

    --pwonly (or -p) will return ONLY the password, in decrypted form.
    --decrypted (or -d) will return the json object with all
        encrypted fields decrypted, except the password.
    --fulldecrypt just like --decrypted, except will return
        the password decrypted as well.

    output format is always pretty printed JSON, unless --pwonly is set.
    """
	click.echo(cli.client.fetchName(name, pwonly, decrypt, fulldecrypt))
github mbr / unleash / unleash / cli.py View on Github external
@click.pass_obj
def publish(unleash, ref, **kwargs):
    opts.update(kwargs)
    unleash.publish(ref)
github TokenMarketNet / sto / sto / cli / main.py View on Github external
@click.pass_obj
def past_issuances(config: BoardCommmadConfiguration):
    """Print out transactions of for tokens issued in the past."""

    logger = config.logger

    from sto.ethereum.issuance import past_issuances

    dbsession = config.dbsession

    txs = list(past_issuances(config, dbsession))

    if txs:
        from sto.ethereum.txservice import EthereumStoredTXService
        EthereumStoredTXService.print_transactions(txs)
        logger.info("See column %sto%s for token contract addresses", colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET)
    else:
github lablup / backend.ai-manager / src / ai / backend / manager / cli / fixture.py View on Github external
@click.pass_obj
def list(cli_ctx):
    '''List all available fixtures.'''
    with cli_ctx.logger:
        log.warning('This command is deprecated.')