Skip to content

Commit 8f64267

Browse files
dlechdpgeorge
authored andcommitted
tools/codeformat.py: Add verbose option to pass to uncrustify and black.
This adds a new command line option `-v` to `tools/codeformat.py` to enable verbose printing of all files that are scanned. Normally `uncrustify` and `black` are called with the `-q` option so setting verbose suppresses the `-q` option and on `black` also enables the `-v` option which makes it print out all file names matching the filter similar to how `uncrustify` does by default.
1 parent 5cfc09f commit 8f64267

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tools/codeformat.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def main():
138138
cmd_parser = argparse.ArgumentParser(description="Auto-format C and Python files.")
139139
cmd_parser.add_argument("-c", action="store_true", help="Format C code only")
140140
cmd_parser.add_argument("-p", action="store_true", help="Format Python code only")
141+
cmd_parser.add_argument("-v", action="store_true", help="Enable verbose output")
141142
cmd_parser.add_argument("files", nargs="*", help="Run on specific globs")
142143
args = cmd_parser.parse_args()
143144

@@ -168,13 +169,21 @@ def batch(cmd, files, N=200):
168169

169170
# Format C files with uncrustify.
170171
if format_c:
171-
batch(["uncrustify", "-q", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"], lang_files(C_EXTS))
172+
command = ["uncrustify", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"]
173+
if not args.v:
174+
command.append("-q")
175+
batch(command, lang_files(C_EXTS))
172176
for file in lang_files(C_EXTS):
173177
fixup_c(file)
174178

175179
# Format Python files with black.
176180
if format_py:
177-
batch(["black", "-q", "--fast", "--line-length=99"], lang_files(PY_EXTS))
181+
command = ["black", "--fast", "--line-length=99"]
182+
if args.v:
183+
command.append("-v")
184+
else:
185+
command.append("-q")
186+
batch(command, lang_files(PY_EXTS))
178187

179188

180189
if __name__ == "__main__":

0 commit comments

Comments
 (0)