|
4 | 4 | import classes.class_es as es
|
5 | 5 |
|
6 | 6 | if __name__ == "__main__":
|
| 7 | + # First, check for arguments passed |
| 8 | + def str2bool(v): |
| 9 | + if isinstance(v, bool): |
| 10 | + return v |
| 11 | + if v.lower() in ('yes', 'true', 't', 'y', '1'): |
| 12 | + return True |
| 13 | + elif v.lower() in ('no', 'false', 'f', 'n', '0'): |
| 14 | + return False |
| 15 | + else: |
| 16 | + raise argparse.ArgumentTypeError('Boolean value expected.') |
| 17 | + |
7 | 18 | # Get arguments
|
8 | 19 | parser = argparse.ArgumentParser(description="Upload directories as release assets.")
|
9 | 20 | parser.add_argument("gh_repo", help="Github repository name, e.g., 'username/repo'", type=str)
|
|
13 | 24 | parser.add_argument("es_password", help="ES instance password value", type=str)
|
14 | 25 | parser.add_argument("es_index", help="ES instance index value", type=str)
|
15 | 26 | parser.add_argument("--es_regex", help="Regex to use to fetch indexed items", type=str, default=".+")
|
16 |
| - parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=bool, default=False) |
17 |
| - parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=bool, default=True) |
| 27 | + parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=str2bool, default=False) |
| 28 | + parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=str2bool, default=True) |
18 | 29 | args = parser.parse_args()
|
19 | 30 |
|
20 | 31 | es_instance = es.index(
|
|
0 commit comments