From 7831f78cc9ccef7331c9176dbecb34f8afc9b54f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 11 Dec 2019 17:24:11 -0800 Subject: 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. --- python/fatcat_export.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'python/fatcat_export.py') diff --git a/python/fatcat_export.py b/python/fatcat_export.py index 1001dbf6..5419e46c 100755 --- a/python/fatcat_export.py +++ b/python/fatcat_export.py @@ -37,11 +37,9 @@ def run_export_changelog(args): json.dumps(entity_to_dict(entry, api_client=args.api.api_client)) + "\n") def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--debug', - action='store_true', - help="enable debugging interface") - parser.add_argument('--host-url', + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('--fatcat-api-url', default="http://localhost:9411/v0", help="connect to this host/port") subparsers = parser.add_subparsers() @@ -72,7 +70,7 @@ def main(): print("tell me what to do!") sys.exit(-1) - args.api = public_api(args.host_url) + args.api = public_api(args.fatcat_api_url) args.func(args) if __name__ == '__main__': -- cgit v1.2.3