From c272e1ccdf1d94bee785e211713bae2aedda84d6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 18 May 2019 10:24:01 +0200 Subject: [PATCH] Add default rest config --- config_full.json.example | 5 +++++ scripts/rest_client.py | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/config_full.json.example b/config_full.json.example index 4c4ad3c58..6603540cf 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -109,6 +109,11 @@ "token": "your_telegram_token", "chat_id": "your_telegram_chat_id" }, + "api_server": { + "enabled": false, + "listen_ip_address": "127.0.0.1", + "listen_port": 8080 + }, "db_url": "sqlite:///tradesv3.sqlite", "initial_state": "running", "forcebuy_enable": false, diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 54b08a03a..4bf46e6fd 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -234,17 +234,19 @@ def load_config(configfile): return {} +def print_commands(): + # Print dynamic help for the different commands + client = FtRestClient(None) + print("Possible commands:") + for x, y in inspect.getmembers(client): + if not x.startswith('_'): + print(f"{x} {getattr(client, x).__doc__}") + + def main(args): - if args.get("show"): - # Print dynamic help for the different commands - client = FtRestClient(None) - print("Possible commands:") - for x, y in inspect.getmembers(client): - if not x.startswith('_'): - print(f"{x} {getattr(client, x).__doc__}") - - return + if args.get("help"): + print_commands() config = load_config(args["config"]) url = config.get("api_server", {}).get("server_url", "127.0.0.1") @@ -256,6 +258,7 @@ def main(args): command = args["command"] if command not in m: logger.error(f"Command {command} not defined") + print_commands() return print(getattr(client, command)(*args["command_arguments"]))