Browse Source

add argument for config file

you can now use "yanic -c/--cfg <file>" to specify the config file
Karsten Böddeker 6 years ago
parent
commit
53ff93366e
1 changed files with 4 additions and 3 deletions
  1. 4 3
      ext-respondd.py

+ 4 - 3
ext-respondd.py

@@ -9,6 +9,7 @@ import lib.helper
 
 parser = argparse.ArgumentParser()
 
+parser.add_argument('-c', '--cfg', default='config.json', metavar='<file>', help='Config File',required=False,)
 parser.add_argument('-d', '--test', action='store_true', help='Test Output', required=False)
 parser.add_argument('-v', '--verbose', action='store_true', help='Verbose Output', required=False)
 parser.add_argument('-t', '--dry-run', action='store_true', help='Dry Run', required=False)
@@ -27,12 +28,12 @@ config = {
 }
 
 try:
-  with open("config.json", 'r') as fh:
+  with open(options['cfg'], 'r') as fh:
     config = lib.helper.merge(config, json.load(fh))
 except IOError:
-  print('no config.json, use defaults')
+  print('no ' + options['cfg'] + ', use defaults')
 
-if options["test"]:
+if options['test']:
   from lib.nodeinfo import Nodeinfo
   from lib.statistics import Statistics
   from lib.neighbours import Neighbours