aboutsummaryrefslogtreecommitdiff
path: root/args.py
blob: a3f400dd299720cb4d9f3c2e09e4d4b4f4ba83e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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