|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | import os |
| 4 | +import argparse |
4 | 5 | import platform |
5 | 6 | import shutil |
6 | 7 | import stat |
@@ -191,12 +192,33 @@ def run_uncrustify(unc_exec): |
191 | 192 |
|
192 | 193 |
|
193 | 194 | def main(): |
194 | | - if sys.argv[1] in ('-b', '--build'): |
| 195 | + parser = argparse.ArgumentParser(description='Run uncrustify among given project.') |
| 196 | + |
| 197 | + group = parser.add_mutually_exclusive_group(required=True) |
| 198 | + |
| 199 | + parser.add_argument('--custom-config-path', type=str, dest='custom_config_path', action='store', help='Path to custom uncrustify configuration.') |
| 200 | + group.add_argument('exclude_list_path', nargs="?", type=str, help='Path to uncstrap exclude list.') |
| 201 | + group.add_argument('--build', dest='build', action='store_true', help='Build uncrustify binary.') |
| 202 | + parser.set_defaults(build=False) |
| 203 | + |
| 204 | + args = parser.parse_args() |
| 205 | + |
| 206 | + if args.build: |
195 | 207 | build_uncrustify(UNC_LINK) |
196 | 208 | sys.exit(0) |
197 | 209 |
|
198 | | - dump_file_list(sys.argv[1]) |
199 | | - download_uncrustify_conf() |
| 210 | + if args.custom_config_path: |
| 211 | + if not os.path.isfile(args.custom_config_path): |
| 212 | + parser.error("--custom-config-path is invalid!") |
| 213 | + shutil.copy(args.custom_config_path, os.getcwd() + "/" + UNC_CONF) |
| 214 | + else: |
| 215 | + download_uncrustify_conf() |
| 216 | + |
| 217 | + if not args.exclude_list_path: |
| 218 | + parser.error("exclude_list_path is not specified!") |
| 219 | + |
| 220 | + dump_file_list(args.exclude_list_path) |
| 221 | + |
200 | 222 | unc_exec = download_uncrustify_bin() |
201 | 223 | run_uncrustify(unc_exec) |
202 | 224 |
|
|
0 commit comments