From 3c6f7cf15fbd380555f18e8101cb33a839df7626 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 23 Mar 2020 16:12:00 +0100 Subject: [PATCH] Adds teosd command line help --- teos/help.py | 13 +++++++++++++ teos/teosd.py | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 teos/help.py diff --git a/teos/help.py b/teos/help.py new file mode 100644 index 0000000..a973b0b --- /dev/null +++ b/teos/help.py @@ -0,0 +1,13 @@ +def show_usage(): + return ( + "USAGE: " + "\n\tpython teosd.py [global options]" + "\n\nGLOBAL OPTIONS:" + "\n\t--btcnetwork \t\tNetwork bitcoind is connected to. Either mainnet, testnet or regtest. Defaults to 'mainnet' (modifiable in conf file)." + "\n\t--btcrpcuser \t\tbitcoind rpcuser. Defaults to 'user' (modifiable in conf file)." + "\n\t--btcrpcpassword \tbitcoind rpcpassword. Defaults to 'passwd' (modifiable in conf file)." + "\n\t--btcrpcconnect \tbitcoind rpcconnect. Defaults to 'localhost' (modifiable in conf file)." + "\n\t--btcrpcport \t\tbitcoind rpcport. Defaults to '8332' (modifiable in conf file)." + "\n\t--datadir \t\tspecify data directory. Defaults to '~\.teos' (modifiable in conf file)." + "\n\t-h --help \t\tshows this message." + ) diff --git a/teos/teosd.py b/teos/teosd.py index ffbd656..dd63bd6 100644 --- a/teos/teosd.py +++ b/teos/teosd.py @@ -10,6 +10,7 @@ from common.cryptographer import Cryptographer from common.tools import setup_logging, setup_data_folder from teos.api import API +from teos.help import show_usage from teos.watcher import Watcher from teos.builder import Builder from teos.carrier import Carrier @@ -160,7 +161,9 @@ if __name__ == "__main__": try: opts, _ = getopt( - argv[1:], "", ["btcnetwork=", "btcrpcuser=", "btcrpcpassword=", "btcrpcconnect=", "btcrpcport=", "datadir="] + argv[1:], + "h", + ["btcnetwork=", "btcrpcuser=", "btcrpcpassword=", "btcrpcconnect=", "btcrpcport=", "datadir=", "help"], ) for opt, arg in opts: if opt in ["--btcnetwork"]: @@ -178,6 +181,8 @@ if __name__ == "__main__": exit("btcrpcport must be an integer") if opt in ["--datadir"]: DATA_DIR = os.path.expanduser(arg) + if opt in ["-h", "--help"]: + exit(show_usage()) except GetoptError as e: exit(e)