File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,14 @@ def add_special_parsers(
251251 default = [],
252252 help = "If specified, --pass-through must be the last argument. Remaining arguments passed to underlying executable" ,
253253 )
254+ format_parser .add_argument (
255+ "--exclude" ,
256+ nargs = "+" ,
257+ default = [],
258+ type = Path ,
259+ help = "Exclude directories from formatting"
260+ )
261+
254262 return {
255263 "hash-to-file" : run_hash_to_file ,
256264 "info" : run_info ,
Original file line number Diff line number Diff line change @@ -192,12 +192,17 @@ def run_code_format(
192192 # Stage all files that are passed through --files
193193 for filename in parsed .files :
194194 clang_formatter .stage_file (Path (filename ))
195+ # List all excluded directories
196+ excluded_dirs = [Path (directory ) for directory in parsed .exclude ]
195197 # Search for files within --dirs and stage them
196198 for dirname in parsed .dirs :
197199 dir_path = Path (dirname )
198200 if not dir_path .is_dir ():
199201 print (f"[INFO] { dir_path } is not a directory. Skipping." )
200202 continue
203+ if dir_path in excluded_dirs :
204+ print (f"[INFO] Excluded { dir_path } from formatting." )
205+ continue
201206 for allowed_ext in clang_formatter .allowed_extensions :
202207 for file in dir_path .rglob (f"*{ allowed_ext } " ):
203208 clang_formatter .stage_file (file )
You can’t perform that action at this time.
0 commit comments