- parser = OptionParser()
- parser.add_option('-f', '--file', default = '/etc/invirt/master.yaml',
- help = 'the configuration file to read from')
- options, args = parser.parse_args()
-
- try: [key] = args
- except: raise invirt_exception( __doc__ )
-
- conf = load()
- components = key.split('.')
- for i, component in enumerate( components ):
- progress = lambda: '.'.join( components[:i] )
- if type( conf ) not in [ dict, list ]:
+ parser = OptionParser(usage = '%prog [options] key',
+ description = __doc__.strip().split('\n\n')[0])
+ parser.add_option('-s', '--src',
+ default = '/etc/invirt/master.yaml',
+ help = 'the source YAML configuration file to read from')
+ parser.add_option('-c', '--cache',
+ default = '/var/lib/invirt/invirt.json',
+ help = 'path to the JSON cache')
+ parser.add_option('-r', '--refresh',
+ action = 'store_true',
+ help = 'force the cache to be regenerated')
+ parser.add_option('-l', '--ls',
+ action = 'store_true',
+ help = 'list node\'s children')
+ opts, args = parser.parse_args()
+
+ if len(args) > 1:
+ raise invirt_exception(__doc__.strip())
+ elif args and args[0]:
+ components = args[0].split('.')
+ else:
+ components = []
+
+ conf = load(opts.src, opts.cache, opts.refresh)
+ for i, component in enumerate(components):
+ progress = '.'.join(components[:i])
+ if type(conf) not in (dict, list):