Skip to content

Instantly share code, notes, and snippets.

@jbuck
Created August 26, 2019 18:31
Show Gist options
  • Save jbuck/e061cf06334e0580dcbc87ea269b44d9 to your computer and use it in GitHub Desktop.
Save jbuck/e061cf06334e0580dcbc87ea269b44d9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import click
import requests
# Create a group for all subcommands
# http://click.palletsprojects.com/en/7.x/quickstart/#nesting-commands
@click.group()
@click.option('--host', default='https://bounceradmin-default.dev.mozaws.net', show_default=True)
@click.option('--username')
@click.option('--password')
@click.pass_context
def cli(ctx, **kwargs):
ctx.obj = dict(**kwargs)
pass
@cli.command()
@click.pass_obj
@click.argument('product')
@click.option('--no-fuzzy/--fuzzy', 'fuzzy', show_default=True)
def location_show(ctx, **kwargs):
click.echo(requests.get(ctx['host'] + '/api/location_show/', params=dict(**kwargs)).text)
@cli.command()
@click.pass_obj
def mirror_list(ctx):
click.echo(requests.get(ctx['host'] + '/api/mirror_list/').text)
if __name__ == '__main__':
cli()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment