How to use the click.command 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 naphatkrit / TigerHost / client / client / tigerhost / commands / keys.py View on Github external
@click.command()
@click.argument('name')
@decorators.print_markers
@decorators.catch_exception(ApiClientResponseError)
@decorators.catch_exception(IOError)
@decorators.store_api_client
@click.pass_context
def remove_key(ctx, name):
    """Removes the key with label NAME.
    """
    api_client = ctx.obj['api_client']
    api_client.remove_key(name)
    click.echo('Key {} removed.'.format(name))
github pioneers / PieCentral / runtime / scripts / mockdawn.py View on Github external
@click.command()
def cli(**options):
    curses.wrapper(main)
github trec-dd / trec-dd-jig / jig / jig.py View on Github external
@click.command()
@click.option('-runid', type=click.STRING, help='Run Identifier')
@click.option('-topic', type=click.STRING, help='Topic ID')
@click.option('-docs', nargs=5, type=click.Tuple([str, str, str, str, str]),
              help='Returned document lists')
def main(runid, topic, docs):
    feedback = step(runid, topic, docs)
    print(runid)
    for f in feedback:
        print(json.dumps(f, indent=4, separators=(',', ': ')))
github PaddlePaddle / PARL / parl / remote / scripts.py View on Github external
@click.command("connect", short_help="Start a worker node.")
@click.option(
    "--address", help="IP address of the master node.", required=True)
@click.option(
    "--cpu_num",
    type=int,
    help="Set number of cpu manually. If not set, it will use all "
    "cpus of this machine.")
def start_worker(address, cpu_num):
    if not is_master_started(address):
        raise Exception("Worker can not connect to the master node, " +
                        "please check if the input address {} ".format(
                            address) + "is correct.")
    cpu_num = str(cpu_num) if cpu_num else ''
    command = [
        sys.executable, "{}/start.py".format(__file__[:-11]), "--name",
        "worker", "--address", address, "--cpu_num",
github Boquete / google-arts-crawler / crawler.py View on Github external
@click.command()
@click.option(
    "--url",
    help="Image URL e.g. https://artsandculture.google.com/asset/madame-moitessier/hQFUe-elM1npbw"
)
@click.option(
    "--size",
    default=DEFAULT_SIZE,
    help="Max image size (default is 12000). Ignored if not using the --url option."
)
@click.option(
    "--raise-errors",
    is_flag=True,
    help="Raise errors instead of just printing them. Useful for debugging."
)
def main(url, size, raise_errors):
    try:
github mobiusklein / ms_deisotope / ms_deisotope / tools / deisotoper / main.py View on Github external
@click.command("deisotope",
               short_help=(
                   "Convert raw mass spectra data into deisotoped neutral mass peak lists written to mzML."
                   " Can accept mzML, mzXML, MGF with either profile or centroided scans."),
               context_settings=dict(help_option_names=['-h', '--help']))
@click.argument("ms-file", type=click.Path(exists=True))
@click.argument("outfile-path", type=click.Path(writable=True))
@click.option("-a", "--averagine", default=["peptide"],
              type=AveragineParamType(),
              help=('Averagine model to use for MS1 scans. '
                    'Either a name or formula. May specify multiple times.'),
              multiple=True)
@click.option("-an", "--msn-averagine", default="peptide",
              type=AveragineParamType(),
              help=('Averagine model to use for MS^n scans. '
                    'Either a name or formula. May specify multiple times.'),
              multiple=True)
github rytilahti / python-miio / miio / extract_tokens.py View on Github external
@click.command()
@click.argument("backup")
@click.option(
    "--write-to-disk",
    type=click.File("wb"),
    help="writes sqlite3 db to a file for debugging",
)
@click.option(
    "--password", type=str, help="password if the android database is encrypted"
)
@click.option(
    "--dump-all", is_flag=True, default=False, help="dump devices without ip addresses"
)
@click.option("--dump-raw", is_flag=True, help="dumps raw rows")
def main(backup, write_to_disk, password, dump_all, dump_raw):
    """Reads device information out from an sqlite3 DB.
     If the given file is an Android backup (.ab), the database
github timdiels / soylent-recipes / soylent_recipes / main.py View on Github external
@click.command(context_settings={'help_option_names': ['-h', '--help']})
@click.version_option(version=__version__)
@click_.option('--usda-data', 'usda_directory', type=click.Path(exists=True, file_okay=False), help='USDA data directory to mine')
def main(usda_directory):
    '''
    Generate soylent recipes. Output is written to recipes.txt
     
    E.g. soylent --usda-data data/usda_nutrient_db_sr28
    '''
    colored_traceback.add_hook()
    logging_.configure('soylent.log')
    logging.getLogger().setLevel(logging.DEBUG)
    nutrition_target = nutrition_target_.from_config()
    foods = foods_.import_usda(Path(usda_directory))
    foods = foods.set_index('description')
    foods = handle_nans(foods, nutrition_target, 10)
    foods = add_energy_components(foods)
github home-assistant / home-assistant-cli / homeassistant_cli / plugins / map.py View on Github external
@click.command('map')
@click.argument(
    'entity',
    required=False,
    autocompletion=autocompletion.entities,  # type: ignore
)
@click.option(
    '--service', default='openstreetmap', type=click.Choice(SERVICE.keys())
)
@pass_context
def cli(ctx: Configuration, service: str, entity: str) -> None:
    """Show the location of the config or an entity on a map."""
    latitude = None
    longitude = None

    if entity:
        thing = entity
github indietyp / hawthorne / cli / helper.py View on Github external
@click.command()
def verify():
  try:
    repo.git.diff_index('HEAD', '--', quiet=True)
    click.echo('You are compatible with the upstream.')
  except GitCommandError:
    click.echo('You are {} compatible with the upstream.'.format(click.style('not',
                                                                             bold=True)))
    stash = click.confirm('Do you want to stash your local changes?')

    if stash:
      repo.git.stash()