summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-25 10:52:27 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-25 10:52:27 +0200
commit7483cb76a22abcd53562e1f44c9a55aba6b6d363 (patch)
treebdc099a157fdf39b78204761431fb2aa04234925
parentbe18d619e69755ee836175d414dada7b6b3cf13e (diff)
Check required config params are in config file
In case a required config param is not in ogcli.json config file, this exits the program with an error code.
-rwxr-xr-xogcli.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/ogcli.py b/ogcli.py
index 09969f5..4672a3a 100755
--- a/ogcli.py
+++ b/ogcli.py
@@ -18,6 +18,12 @@ class CLI():
except:
sys.exit(f'ERROR: cannot open {OG_CLI_CFG_PATH}')
+ required_cfg_params = {'api_token', 'ip', 'port'}
+ difference_cfg_params = required_cfg_params - self.cfg.keys()
+ if len(difference_cfg_params) > 0:
+ sys.exit(f'Missing {difference_cfg_params} key in '
+ f'json config file')
+
self.ogcli = OgCLI(self.cfg)
parser = argparse.ArgumentParser(prog='ogcli')