diff options
Diffstat (limited to 'tools/codeformat.py')
-rwxr-xr-x | tools/codeformat.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/codeformat.py b/tools/codeformat.py index 1c865663a..13a699065 100755 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -151,6 +151,11 @@ def main(): 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( + "-f", + action="store_true", + help="Filter files provided on the command line against the default list of files to check.", + ) cmd_parser.add_argument("files", nargs="*", help="Run on specific globs") args = cmd_parser.parse_args() @@ -162,6 +167,16 @@ def main(): files = [] if args.files: files = list_files(args.files) + if args.f: + # Filter against the default list of files. This is a little fiddly + # because we need to apply both the inclusion globs given in PATHS + # as well as the EXCLUSIONS, and use absolute paths + files = set(os.path.abspath(f) for f in files) + all_files = set(list_files(PATHS, EXCLUSIONS, TOP)) + if args.v: # In verbose mode, log any files we're skipping + for f in files - all_files: + print("Not checking: {}".format(f)) + files = list(files & all_files) else: files = list_files(PATHS, EXCLUSIONS, TOP) |