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

Cli: simplify command line

parent 9d1c4e37
...@@ -2,13 +2,11 @@ import click ...@@ -2,13 +2,11 @@ import click
import sys import sys
from urlchecker_bot import create_bot from urlchecker_bot import create_bot
@click.command(short_help="Runs url checker bot.")
@click.group() @click.option('--run', '-r', help="The bot operation to run.",
def runUrlChecker(): show_default=True,
pass default='status',
type=click.Choice(['crawl', 'status']))
@runUrlChecker.command("bot", short_help="Runs url checker bot.")
@click.option( @click.option(
"--sqlite", "-s", help="The path of the sqlite DB. (default: :memory:)" "--sqlite", "-s", help="The path of the sqlite DB. (default: :memory:)"
) )
...@@ -18,7 +16,7 @@ def runUrlChecker(): ...@@ -18,7 +16,7 @@ def runUrlChecker():
@click.option( @click.option(
"--configuration", "-f", help="The path of the configuration file." "--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") # click.echo("Running url checker bot")
mapping = {} mapping = {}
...@@ -34,7 +32,12 @@ def runWebBot(sqlite, dns, url, domain, configuration): ...@@ -34,7 +32,12 @@ def runWebBot(sqlite, dns, url, domain, configuration):
if dns: if dns:
mapping["DNS"] = dns mapping["DNS"] = dns
bot = create_bot(cfgfile=configuration, mapping=mapping) bot = create_bot(cfgfile=configuration, mapping=mapping)
if run == 'status':
return bot.status()
elif run == 'crawl':
return bot.run() return bot.run()
else:
raise NotImplementedError('Unexpected run: %s' % run)
if __name__ == "__main__": 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