import argparse def get_args(): parser = argparse.ArgumentParser() parser.add_argument( "--endpoint", default="https://hatecomputers.club", help="API endpoint" ) parser.add_argument( "--api-key-file", default="apikey.secret", help="path to file containing the API key", ) parser.add_argument( "--log-level", default="INFO", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], ) parser.add_argument( "--public-suffixes", default="hatecomputers.club", help="comma separated list of public suffixes", ) parser.add_argument( "--dns-propogate-time", default=20, type=int, help="time to sleep to allow DNS to propogate", ) parser.add_argument( "--certbot", action="store_true", default=False, help="enable certbot mode" ) parser.add_argument( "--certbot-domain", required=False, help="splat/domain to validate with certbot" ) parser.add_argument( "--certbot-validation", required=False, help="validation token for certbot" ) parser.add_argument( "--create", action="store_true", default=False, help="upload records file to API to sync", ) parser.add_argument("--records-file", default="records.json", help="records file") args = parser.parse_args() if (args.certbot) and (not args.certbot_domain): parser.error("--certbot-domain is required when --certbot is used") if (args.certbot) and (not args.certbot_validation): parser.error("--certbot-validation is required when --certbot is used") if args.certbot: args.public_suffixes = args.public_suffixes.split(",") return args