From a03528406f84b7fbc3ac7255713aa4f04e67b7f3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Jun 2024 09:16:38 +0200 Subject: [PATCH] Split client arguments to accept kwarguments --- ft_client/freqtrade_client/ft_client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ft_client/freqtrade_client/ft_client.py b/ft_client/freqtrade_client/ft_client.py index 9dbb69b74..3c450d1df 100644 --- a/ft_client/freqtrade_client/ft_client.py +++ b/ft_client/freqtrade_client/ft_client.py @@ -102,7 +102,18 @@ def main_exec(parsed: Dict[str, Any]): print_commands() return - print(json.dumps(getattr(client, command)(*parsed["command_arguments"]))) + # Split arguments with = into key/value pairs + kwargs = {x.split("=")[0]: x.split("=")[1] for x in parsed["command_arguments"] if "=" in x} + args = [x for x in parsed["command_arguments"] if "=" not in x] + try: + res = getattr(client, command)(*args, **kwargs) + print(json.dumps(res)) + except TypeError as e: + logger.error(f"Error executing command {command}: {e}") + sys.exit(1) + except Exception as e: + logger.error(f"Fatal Error executing command {command}: {e}") + sys.exit(1) def main():