message: tools: add argsparse to check format. Allow additional excluded prefixes
diff: #!/usr/bin/env python
  +import argparse
  import re
  import os
  import os.path
  import sys
  -USAGE = "usage: check_format.py <check|fix> [<directory|file>]"
  -
  EXCLUDED_PREFIXES = ("./generated/", "./thirdparty/", "./build", "./.git/",
  "./bazel-")
  SUFFIXES = (".cc", ".h", "BUILD")
  @@ -94,16 +93,18 @@ def checkFormatVisitor(arg, dir_name, names):
  if __name__ == "__main__":
  - if len(sys.argv) != 2 and len(sys.argv) != 3:
  - print(USAGE)
  - sys.exit(1)
  -
  - operation_type = sys.argv[1]
  - target_path = sys.argv[2] if len(sys.argv) == 3 else "."
  -
  - if operation_type not in {"check", "fix"}:
  - print(USAGE)
  - sys.exit(1)
  + parser = argparse.ArgumentParser(description='Check or fix file format.')
  + parser.add_argument('operation_type', type=str, choices=['check', 'fix'],
  + help="specify if the run should 'check' or 'fix' format.")
  + parser.add_argument('target_path', type=str, nargs="?", default=".", help="specify the root directory"
  + " for the script to recurse over. Default '.'.")
  + parser.add_argument('--add-excluded-prefixes', type=str, nargs="+", help="exclude additional prefixes.")
  + args = parser.parse_args()
  +
  + operation_type = args.operation_type
  + target_path = args.target_path
  + if args.add_excluded_prefixes:
  + EXCLUDED_PREFIXES += tuple(args.add_excluded_prefixes)
  if os.path.isfile(target_path):
  checkFormat("./" + target_path)
  