From c8f3e229c80cd72eb0b44da023ad976419fa2c03 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 9 Jan 2023 21:26:28 -0500 Subject: [PATCH] Move argument parsing into a function --- mailman_sync.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mailman_sync.py b/mailman_sync.py index 399013f..cd2533a 100755 --- a/mailman_sync.py +++ b/mailman_sync.py @@ -103,7 +103,8 @@ def main(mailman_bin: Path, api: str, api_auth: str, list_suffix: str, dry_run: print(f"Skipping {list_name}, as it does not exist in Mailman") -if __name__ == "__main__": + +def parse_arguments(): argp = argparse.ArgumentParser(description=__doc__) argp.add_argument( "--bin", @@ -119,7 +120,11 @@ if __name__ == "__main__": action="store_true", help="Don't make changes, just print what would happen", ) - args = argp.parse_args() + return argp.parse_args() + + +if __name__ == "__main__": + args = parse_arguments() if "API_AUTH" in os.environ: api_auth = os.environ.get("API_AUTH")