summaryrefslogtreecommitdiffstats
path: root/python/fatcat_worker.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-12-11 17:24:11 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-12-11 17:24:14 -0800
commit7831f78cc9ccef7331c9176dbecb34f8afc9b54f (patch)
tree53d82b7e044fd228d18eef9a5b682ecb6ce22bb4 /python/fatcat_worker.py
parente5199300f8c4be2d2c60c18e341d774ae44a1def (diff)
downloadfatcat-7831f78cc9ccef7331c9176dbecb34f8afc9b54f.tar.gz
fatcat-7831f78cc9ccef7331c9176dbecb34f8afc9b54f.zip
improve argparse usage
Use --fatcat-api-url instead of (ambiguous) --host-url for commands that aren't deployed/running via systemd. TODO: update the other --host-url usage, and either roll-out change consistently or support the old arg as an alias during cut-over Use argparse.ArgumentDefaultsHelpFormatter (thanks Martin!) Add help messages for all sub-commands, both as documentation and as a way to get argparse to print available commands in a more readable format.
Diffstat (limited to 'python/fatcat_worker.py')
-rwxr-xr-xpython/fatcat_worker.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/python/fatcat_worker.py b/python/fatcat_worker.py
index c2120bae..bfb87a72 100755
--- a/python/fatcat_worker.py
+++ b/python/fatcat_worker.py
@@ -48,10 +48,8 @@ def run_elasticsearch_container(args):
worker.run()
def main():
- parser = argparse.ArgumentParser()
- parser.add_argument('--debug',
- action='store_true',
- help="enable debug logging")
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--api-host-url',
default="http://localhost:9411/v0",
help="fatcat API host/port to use")
@@ -63,16 +61,19 @@ def main():
help="Kafka topic namespace to use (eg, prod, qa, dev)")
subparsers = parser.add_subparsers()
- sub_changelog = subparsers.add_parser('changelog')
+ sub_changelog = subparsers.add_parser('changelog',
+ help="poll fatcat API for changelog entries, push to kafka")
sub_changelog.set_defaults(func=run_changelog)
sub_changelog.add_argument('--poll-interval',
help="how long to wait between polling (seconds)",
default=5.0, type=float)
- sub_entity_updates = subparsers.add_parser('entity-updates')
+ sub_entity_updates = subparsers.add_parser('entity-updates',
+ help="poll kafka for changelog entries; push entity changes to various kafka topics")
sub_entity_updates.set_defaults(func=run_entity_updates)
- sub_elasticsearch_release = subparsers.add_parser('elasticsearch-release')
+ sub_elasticsearch_release = subparsers.add_parser('elasticsearch-release',
+ help="consume kafka feed of new/updated releases, transform and push to search")
sub_elasticsearch_release.set_defaults(func=run_elasticsearch_release)
sub_elasticsearch_release.add_argument('--elasticsearch-backend',
help="elasticsearch backend to connect to",
@@ -81,7 +82,8 @@ def main():
help="elasticsearch index to push into",
default="fatcat_release_v03")
- sub_elasticsearch_container = subparsers.add_parser('elasticsearch-container')
+ sub_elasticsearch_container = subparsers.add_parser('elasticsearch-container',
+ help="consume kafka feed of new/updated containers, transform and push to search")
sub_elasticsearch_container.set_defaults(func=run_elasticsearch_container)
sub_elasticsearch_container.add_argument('--elasticsearch-backend',
help="elasticsearch backend to connect to",