Build or extend an arg parser for the cloud-id utility. @param parser: Optional existing ArgumentParser instance representing the query subcommand which will be extended to support the args of this utility. @returns: ArgumentParser with proper argument configuration.
(parser=None)
| 17 | |
| 18 | |
| 19 | def get_parser(parser=None): |
| 20 | """Build or extend an arg parser for the cloud-id utility. |
| 21 | |
| 22 | @param parser: Optional existing ArgumentParser instance representing the |
| 23 | query subcommand which will be extended to support the args of |
| 24 | this utility. |
| 25 | |
| 26 | @returns: ArgumentParser with proper argument configuration. |
| 27 | """ |
| 28 | default_instance_json = read_cfg_paths().get_runpath("instance_data") |
| 29 | if not parser: |
| 30 | parser = argparse.ArgumentParser( |
| 31 | prog=NAME, |
| 32 | description="Report the canonical cloud-id for this instance", |
| 33 | ) |
| 34 | parser.add_argument( |
| 35 | "-j", |
| 36 | "--json", |
| 37 | action="store_true", |
| 38 | default=False, |
| 39 | help="Report all standardized cloud-id information as json.", |
| 40 | ) |
| 41 | parser.add_argument( |
| 42 | "-l", |
| 43 | "--long", |
| 44 | action="store_true", |
| 45 | default=False, |
| 46 | help="Report extended cloud-id information as tab-delimited string.", |
| 47 | ) |
| 48 | parser.add_argument( |
| 49 | "-i", |
| 50 | "--instance-data", |
| 51 | type=str, |
| 52 | default=default_instance_json, |
| 53 | help=( |
| 54 | "Path to instance-data.json file. " |
| 55 | f"Default is {default_instance_json}" |
| 56 | ), |
| 57 | ) |
| 58 | return parser |
| 59 | |
| 60 | |
| 61 | def handle_args(name, args): |
no test coverage detected