better arg parsing

This commit is contained in:
Elizabeth Hunt 2024-04-10 16:17:08 -06:00
parent 0c7ac77127
commit 06926fd786
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 2909B9A7FF6213EE
2 changed files with 11 additions and 4 deletions

13
args.py
View File

@ -6,7 +6,6 @@ def get_args():
parser.add_argument("--endpoint", default="https://hatecomputers.club") parser.add_argument("--endpoint", default="https://hatecomputers.club")
parser.add_argument("--api-key-file", default="apikey.secret") parser.add_argument("--api-key-file", default="apikey.secret")
parser.add_argument("--records-file", default="records.json")
parser.add_argument( parser.add_argument(
"--log-level", "--log-level",
default="INFO", default="INFO",
@ -14,9 +13,17 @@ def get_args():
) )
parser.add_argument("--certbot", action="store_true", default=False) parser.add_argument("--certbot", action="store_true", default=False)
parser.add_argument("--acme-url", required=True) parser.add_argument("--acme-url", required=False)
parser.add_argument("--acme-storage", default="acme.json") parser.add_argument("--acme-storage", default="acme.json")
parser.add_argument("--sync", action="store_true", default=False) parser.add_argument("--sync", action="store_true", default=False)
parser.add_argument("--records-file", default="records.json")
return parser.parse_args() args = parser.parse_args()
if (args.certbot) and (not args.acme_url):
parser.error("--acme-url is required when --certbot is used")
if (args.certbot) and (args.sync):
parser.error("--sync cannot be used in combination with --certbot")
return args

View File

@ -20,5 +20,5 @@ class HatecomputersDNSAdapter:
for record in dns_entries: for record in dns_entries:
self.post_record(record) self.post_record(record)
self.logger.info(f"sleeping for {eepy_time}") self.logger.info(f"eeping out for {eepy_time}s")
time.sleep(eepy_time) time.sleep(eepy_time)