2024-04-10 18:13:16 -04:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
def get_args():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
2024-04-11 13:17:58 -04:00
|
|
|
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",
|
|
|
|
)
|
2024-04-10 18:13:16 -04:00
|
|
|
parser.add_argument(
|
|
|
|
"--log-level",
|
|
|
|
default="INFO",
|
|
|
|
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
|
|
)
|
|
|
|
|
2024-04-11 13:17:58 -04:00
|
|
|
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"
|
|
|
|
)
|
2024-04-10 18:13:16 -04:00
|
|
|
|
2024-04-11 13:17:58 -04:00
|
|
|
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")
|
2024-04-10 18:17:08 -04:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2024-04-11 13:17:58 -04:00
|
|
|
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(",")
|
2024-04-10 18:13:16 -04:00
|
|
|
|
2024-04-10 18:17:08 -04:00
|
|
|
return args
|