Commit 0216bd84 authored by Romain Courteaud's avatar Romain Courteaud

Cli: simplify command line

parent 9d1c4e37
......@@ -2,13 +2,11 @@ import click
import sys
from urlchecker_bot import create_bot
@click.group()
def runUrlChecker():
pass
@runUrlChecker.command("bot", short_help="Runs url checker bot.")
@click.command(short_help="Runs url checker bot.")
@click.option('--run', '-r', help="The bot operation to run.",
show_default=True,
default='status',
type=click.Choice(['crawl', 'status']))
@click.option(
"--sqlite", "-s", help="The path of the sqlite DB. (default: :memory:)"
)
......@@ -18,7 +16,7 @@ def runUrlChecker():
@click.option(
"--configuration", "-f", help="The path of the configuration file."
)
def runWebBot(sqlite, dns, url, domain, configuration):
def runUrlChecker(run, sqlite, dns, url, domain, configuration):
# click.echo("Running url checker bot")
mapping = {}
......@@ -34,7 +32,12 @@ def runWebBot(sqlite, dns, url, domain, configuration):
if dns:
mapping["DNS"] = dns
bot = create_bot(cfgfile=configuration, mapping=mapping)
if run == 'status':
return bot.status()
elif run == 'crawl':
return bot.run()
else:
raise NotImplementedError('Unexpected run: %s' % run)
if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment