fix: parse arguments starting with a dash correctly
This commit is contained in:
parent
524a45fbc3
commit
067e7eb125
1 changed files with 13 additions and 11 deletions
|
@ -19,19 +19,21 @@ handlers = {
|
||||||
'http': HTTPHandler,
|
'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:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(
|
args = Args(sys.argv)
|
||||||
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()
|
|
||||||
|
|
||||||
config = read_config(None)
|
config = read_config(None)
|
||||||
|
|
||||||
record_name = f'_acme-challenge.{args.domain}'
|
record_name = f'_acme-challenge.{args.domain}'
|
||||||
|
|
Loading…
Reference in a new issue