fix: parse arguments starting with a dash correctly

This commit is contained in:
ptrcnull 2024-06-21 15:18:09 +02:00
parent 524a45fbc3
commit 067e7eb125
Signed by: ptrcnull
GPG key ID: 411F7B30801DD9CA

View file

@ -19,19 +19,21 @@ handlers = {
'http': HTTPHandler,
}
class Args:
def __init__(self, argv):
# one of 'begin', 'done', 'failed'
self.method = argv[1]
# challenge type (dns-01, http-01 or tls-alpn-01)
self.type = argv[2]
# the identifier the challenge refers to (domain name)
self.domain = argv[3]
# the challenge token
self.token = argv[4]
# the key authorization (DNS record contents, etc.)
self.auth = argv[5]
def main() -> None:
parser = argparse.ArgumentParser(
prog='nyacme-hook',
description='nyacme hook (not meant to be ran manually)'
)
parser.add_argument('method', help='one of begin, done or failed')
parser.add_argument('type', help='challenge type (dns-01, http-01 or tls-alpn-01)')
parser.add_argument('domain', help='the identifier the challenge refers to (domain name)')
parser.add_argument('token', help='the challenge token')
parser.add_argument('auth', help='the key authorization (DNS record contents, etc.)')
args = parser.parse_args()
args = Args(sys.argv)
config = read_config(None)
record_name = f'_acme-challenge.{args.domain}'