Skip to content

Commit dcb5462

Browse files
committed
Add --exclude argument for excluding directories from formatting
1 parent 19afa8c commit dcb5462

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/fprime/util/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

src/fprime/util/commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)