summaryrefslogtreecommitdiffstats
path: root/python/fatcat_cleanup.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_cleanup.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_cleanup.py')
-rwxr-xr-xpython/fatcat_cleanup.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python/fatcat_cleanup.py b/python/fatcat_cleanup.py
index 42887299..a7c80965 100755
--- a/python/fatcat_cleanup.py
+++ b/python/fatcat_cleanup.py
@@ -14,8 +14,9 @@ def run_files(args):
JsonLinePusher(fmi, args.json_file).run()
def main():
- parser = argparse.ArgumentParser()
- 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")
parser.add_argument('--batch-size',
@@ -29,7 +30,8 @@ def main():
default=False, type=bool)
subparsers = parser.add_subparsers()
- sub_files = subparsers.add_parser('files')
+ sub_files = subparsers.add_parser('files',
+ help="attempt metadata cleanups over a list of file entities")
sub_files.set_defaults(
func=run_files,
auth_var="FATCAT_AUTH_WORKER_CLEANUP",
@@ -50,7 +52,7 @@ def main():
args.editgroup_description_override = os.environ.get('FATCAT_EDITGROUP_DESCRIPTION')
args.api = authenticated_api(
- args.host_url,
+ args.fatcat_api_url,
# token is an optional kwarg (can be empty string, None, etc)
token=os.environ.get(args.auth_var))
args.func(args)