| Philip Joseph | f9c7222 | 2016-10-02 23:31:02 +0530 | [diff] [blame^] | 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) |