diff options
author | David Lechner <david@pybricks.com> | 2020-05-27 11:10:40 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-05-29 22:59:56 +1000 |
commit | 8f642677f724e725813155f74e5934b8c94fc1c4 (patch) | |
tree | 3bb6d73f75ef1fc10fe9ebb1a69b77b348c3527d /tools/codeformat.py | |
parent | 5cfc09ffca3203eb474aec478b8baf1f35fd2a0b (diff) | |
download | micropython-8f642677f724e725813155f74e5934b8c94fc1c4.tar.gz micropython-8f642677f724e725813155f74e5934b8c94fc1c4.zip |
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.
Diffstat (limited to 'tools/codeformat.py')
-rwxr-xr-x | tools/codeformat.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/codeformat.py b/tools/codeformat.py index 2fe72ef33d..5aef4ccfbf 100755 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -138,6 +138,7 @@ def main(): cmd_parser = argparse.ArgumentParser(description="Auto-format C and Python files.") cmd_parser.add_argument("-c", action="store_true", help="Format C code only") cmd_parser.add_argument("-p", action="store_true", help="Format Python code only") + cmd_parser.add_argument("-v", action="store_true", help="Enable verbose output") cmd_parser.add_argument("files", nargs="*", help="Run on specific globs") args = cmd_parser.parse_args() @@ -168,13 +169,21 @@ def main(): # Format C files with uncrustify. if format_c: - batch(["uncrustify", "-q", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"], lang_files(C_EXTS)) + command = ["uncrustify", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"] + if not args.v: + command.append("-q") + batch(command, lang_files(C_EXTS)) for file in lang_files(C_EXTS): fixup_c(file) # Format Python files with black. if format_py: - batch(["black", "-q", "--fast", "--line-length=99"], lang_files(PY_EXTS)) + command = ["black", "--fast", "--line-length=99"] + if args.v: + command.append("-v") + else: + command.append("-q") + batch(command, lang_files(PY_EXTS)) if __name__ == "__main__": |