~ibmcharmers/charms/trusty/layer-ibm-wxs-container/devel

« back to all changes in this revision

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

  • Committer: anitanayak at ibm
  • Date: 2017-03-13 07:13:16 UTC
  • Revision ID: anitanayak@in.ibm.com-20170313071316-fpdhvfvejewbur4o
check-in for trusty layer-ibm-wxs-container after updated for new version

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)