Skip to content

Commit c62c1a5

Browse files
uncrustify: add custom_config argument
1 parent d6fe47d commit c62c1a5

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

uncstrap/uncstrap.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import argparse
45
import platform
56
import shutil
67
import stat
@@ -191,12 +192,33 @@ def run_uncrustify(unc_exec):
191192

192193

193194
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:
195207
build_uncrustify(UNC_LINK)
196208
sys.exit(0)
197209

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+
200222
unc_exec = download_uncrustify_bin()
201223
run_uncrustify(unc_exec)
202224

0 commit comments

Comments
 (0)