How to use the click.argument 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 OCR-D / core / ocrd / ocrd / cli / workspace.py View on Github external
@click.argument('ID')
@pass_workspace
def set_id(ctx, id):   # pylint: disable=redefined-builtin
    """
    Set METS ID.

    If one of the supported identifier mechanisms is used, will set this identifier.

    Otherwise will create a new {{ ID }}.
    """
    workspace = Workspace(ctx.resolver, directory=ctx.directory, mets_basename=ctx.mets_basename)
    workspace.mets.unique_identifier = id
    workspace.save_mets()
github wongnai / eastern / eastern / cli.py View on Github external
@click.argument("file", type=click.Path(exists=True))
@click.argument("namespace", default="default")
@click.argument("tag")
@click.option("--set", "-s", callback=parse_set, multiple=True)
@click.option("--edit", "-e", is_flag=True, help="Edit generated manifest before deploying")
@click.option("--timeout", default=300, help="Wait timeout (default 300s, 0 to disable)")
@click.pass_context
def job(ctx, file, namespace, tag, edit, timeout, **kwargs):
    exit_status = 0
    kwargs["set"].append(("IMAGE_TAG", tag))
    manifest = format_yaml(file, namespace, edit=edit, extra=kwargs["set"], print=False)

    # Modify the name to contain imageTag
    manifest = list(yaml.load_all(manifest))

    found_job = False
    for item in manifest:
github RunestoneInteractive / RunestoneComponents / runestone / __main__.py View on Github external
@click.argument("directive", nargs=-1)
def doc(directive=None, list=None):
    """
    Show Format and all options for a runestone directive
    """
    if list:
        print("Runestone Directives List")
        print("  ", "\n   ".join(sorted(cmap.keys())))
        return

    if directive:
        directive = directive[0]
        if directive in cmap:
            print(cmap[directive].__doc__)
        else:
            print("""Unknown Directive.  Possible values are""")
            print("  ", "\n   ".join(sorted(cmap.keys())))
github zhmcclient / python-zhmcclient / zhmccli / _cmd_partition.py View on Github external
@click.argument('CPC', type=str, metavar='CPC')
@click.argument('PARTITION', type=str, metavar='PARTITION')
@click.pass_obj
def partition_unmount_iso(cmd_ctx, cpc, partition):
    """
    Unmount an ISO image from a partition.

    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_partition_unmount_iso(cmd_ctx, cpc,
                                                          partition))
github globus / globus-cli / globus_cli / parsing / shared_options.py View on Github external
def server_id_arg(f):
    """
    Unmodifiable `SERVER_ID` argument for Transfer Endpoint Server management.
    """
    return click.argument("server_id")(f)
github digidotcom / python-wpa-supplicant / wpa_supplicant / cli.py View on Github external
@click.argument('ifname', 'e.g. wlan0')
def remove_interface(ifname):
    """Method: Deregisters a wireless interface from wpa_supplicant"""
    with supplicant() as supp:
        iface = supp.get_interface(ifname)
        supp.remove_interface(iface.get_path())
github mcs07 / ChemDataExtractor / chemdataextractor / cli / __init__.py View on Github external
@click.argument('input', type=click.File('rb'), default=click.get_binary_stream('stdin'))
@click.pass_obj
def extract(ctx, input, output):
    """Run ChemDataExtractor on a document."""
    log.info('chemdataextractor.extract')
    log.info('Reading %s' % input.name)
    doc = Document.from_file(input, fname=input.name)
    records = [record.serialize(primitive=True) for record in doc.records]
    jsonstring = json.dumps(records, indent=2, ensure_ascii=False)
    output.write(jsonstring)
github cxmcc / ecsctl / ecsctl / cmds.py View on Github external
@click.argument('command', nargs=-1)
@click.pass_context
def exec_command(ctx, task, command, stdin, tty, cluster, docker_port,
                 docker_api_version, container):
    if not cluster:
        cluster = ctx.obj['cluster']
    if not docker_port:
        docker_port = int(ctx.obj['docker_port'])
    if not docker_api_version:
        docker_api_version = ctx.obj['docker_api_version']
    bw = ctx.obj['bw']
    pty = Pty(bw=bw, task=task, command=command, cluster=cluster,
              tty=tty, stdin=stdin, port=docker_port,
              api_version=docker_api_version,
              container=container)
    pty.exec_command()
github libratom / libratom / libratom / cli / cli.py View on Github external
@click.argument(
    "src", metavar="[SOURCE]", type=PathPath(exists=True, resolve_path=True),
)
@click.option(
    "-v",
    "--verbose",
    count=True,
    callback=set_log_level_from_verbose,
    help="Increase verbosity (can be repeated).",
    expose_value=False,
)
@click.option("-p", "--progress", is_flag=True, help="Show progress.")
def entities(out, spacy_model, include_message_contents, jobs, src, progress):
    """
    Extract named entities from a PST or mbox file, or a directory of one or more PST and mbox files.

    If SOURCE is a directory it will be walked recursively. Non-PST and non-mbox files will be skipped.
github zmei-framework / generator / util / zmei_cli / main.py View on Github external
    @click.argument('app', nargs=-1)
    def migrate(app, **args):
        gen(auto=True, app=app)