Move argument parsing into a function

This commit is contained in:
Adam Goldsmith 2023-01-09 21:26:28 -05:00
parent d8284f4475
commit c8f3e229c8

View File

@ -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") print(f"Skipping {list_name}, as it does not exist in Mailman")
if __name__ == "__main__":
def parse_arguments():
argp = argparse.ArgumentParser(description=__doc__) argp = argparse.ArgumentParser(description=__doc__)
argp.add_argument( argp.add_argument(
"--bin", "--bin",
@ -119,7 +120,11 @@ if __name__ == "__main__":
action="store_true", action="store_true",
help="Don't make changes, just print what would happen", 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: if "API_AUTH" in os.environ:
api_auth = os.environ.get("API_AUTH") api_auth = os.environ.get("API_AUTH")