~ibmcharmers/charms/trusty/layer-ibm-mobilefirst-server/devel

« back to all changes in this revision

Viewing changes to deps/layer/layer-basic/bin/layer_option

  • Committer: Suchitra Venugopal
  • Date: 2016-09-06 09:48:53 UTC
  • Revision ID: suchvenu@in.ibm.com-20160906094853-1n09myeisek096nm
IBM MobileFirst Server

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
 
 
3
import sys
 
4
sys.path.append('lib')
 
5
 
 
6
import argparse
 
7
from charms.layer import options
 
8
 
 
9
 
 
10
parser = argparse.ArgumentParser(description='Access layer options.')
 
11
parser.add_argument('section',
 
12
                    help='the section, or layer, the option is from')
 
13
parser.add_argument('option',
 
14
                    help='the option to access')
 
15
 
 
16
args = parser.parse_args()
 
17
value = options(args.section).get(args.option, '')
 
18
if isinstance(value, bool):
 
19
    sys.exit(0 if value else 1)
 
20
elif isinstance(value, list):
 
21
    for val in value:
 
22
        print(val)
 
23
else:
 
24
    print(value)