started adding simple configuration-loading module and getconfig frontend; checkpoint...
[invirt/packages/invirt-base.git] / files / usr / sbin / invirt-getconf
diff --git a/files/usr/sbin/invirt-getconf b/files/usr/sbin/invirt-getconf
new file mode 100644 (file)
index 0000000..cbb0a85
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+from invirt.config import load
+from sys import argv, stderr
+
+def main( argv ):
+    try: command, key = argv
+    except: print >> stderr, 'invirt-getconf KEY'
+    conf = load()
+    for component in key.split('.')[:-1]:
+        if component.isdigit(): component = int( component )
+        conf = conf[ component ]
+    print conf[key]
+
+if __name__ == '__main__':
+    main( argv )
+
+# vim:et:sw=4:ts=4