Add a -o option to override the configuration
authorGiorgos Verigakis <verigak@gmail.com>
Thu, 2 Feb 2012 14:15:44 +0000 (16:15 +0200)
committerGiorgos Verigakis <verigak@gmail.com>
Thu, 2 Feb 2012 14:15:44 +0000 (16:15 +0200)
kamaki/cli.py

index b4b8bdd..152eda1 100755 (executable)
@@ -739,6 +739,9 @@ def main():
             help='use verbose output')
     parser.add_option('-d', dest='debug', action='store_true', default=False,
             help='use debug output')
+    parser.add_option('-o', dest='options', action='append',
+            metavar='KEY=VAL',
+            help='override a config value (can be used multiple times)')
     
     # Do a preliminary parsing, ignore any errors since we will print help
     # anyway if we don't reach the main parsing.
@@ -760,6 +763,13 @@ def main():
         log.error('%s', e.args[0])
         exit(1)
     
+    for option in options.options or []:
+        key, sep, val = option.partition('=')
+        if not sep:
+            log.error('Invalid option "%s"', option)
+            exit(1)
+        config.override(key.strip(), val.strip())
+    
     apis = config.get('apis').split()
     
     # Find available groups based on the given APIs