From 60877762c0e7ebf03b5e15aa538bc6b093f302b2 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Wed, 5 Aug 2020 12:38:09 +0200 Subject: [PATCH] [cli] moved run command to its own file --- halfapi/cli/__init__.py | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/halfapi/cli/__init__.py b/halfapi/cli/__init__.py index a4c3a26..949a11f 100644 --- a/halfapi/cli/__init__.py +++ b/halfapi/cli/__init__.py @@ -51,34 +51,6 @@ def cli(ctx, version): if ctx.invoked_subcommand is None: return run() -@click.option('--host', default=None) -@click.option('--port', default=None) -@cli.command() -def run(host, port): - from halfapi.conf import (HOST, PORT, - PRODUCTION, BASE_DIR) - - if not host: - host = HOST - - if not port: - port = PORT - - port = int(port) - - debug = reload = not PRODUCTION - log_level = 'info' if PRODUCTION else 'debug' - - click.echo('Launching application') - - sys.path.insert(0, BASE_DIR) - list_routes(DOMAINS) - - uvicorn.run('halfapi.app:application', - host=host, - port=int(port), - log_level=log_level, - reload=reload) def delete_domain(domain): @@ -121,12 +93,11 @@ def routes(domain, update): list_routes(domain) -def list_routes(domains): - for domain in domains: - print(f'\nDomain {domain}') - routes = Acl(domain=domain) - for route in routes.select(): - print('-', route) +def list_routes(domain): + print(f'\nDomain {domain}') + routes = Acl(domain=domain) + for route in routes.select(): + print('-', route) def update_db(domains):