From 9b27c2da0151f767a9573e235b3661e3896d0232 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:37:48 +0200 Subject: [PATCH] argparser respect boolean arguments (#842) --- lnbits/server.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lnbits/server.py b/lnbits/server.py index 26a4691b..e9849851 100644 --- a/lnbits/server.py +++ b/lnbits/server.py @@ -20,15 +20,19 @@ from lnbits.settings import HOST, PORT def main(ctx, port: int, host: str, ssl_keyfile: str, ssl_certfile: str): """Launched with `poetry run lnbits` at root level""" # this beautiful beast parses all command line arguments and passes them to the uvicorn server - d = dict( - [ - ( - item[0].strip("--").replace("-", "_"), - int(item[1]) if item[1].isdigit() else item[1], + d = dict() + for a in ctx.args: + item = a.split("=") + if len(item) > 1: # argument like --key=value + print(a, item) + d[item[0].strip("--").replace("-", "_")] = ( + int(item[1]) # need to convert to int if it's a number + if item[1].isdigit() + else item[1] ) - for item in zip(*[iter(ctx.args)] * 2) - ] - ) + else: + d[a.strip("--")] = True # argument like --key + config = uvicorn.Config( "lnbits.__main__:app", port=port,