config-clang-tidy: add format subcommand
The 'merge' subcommand can be used for formatting, if the `--reference`
is the same clang-tidy file as the input, but this is not convenient
for users. Add a 'format' subcommand that does the expected.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If51ded84e85f6f285a6b5d1df0764ff20b1b2064
diff --git a/tools/config-clang-tidy b/tools/config-clang-tidy
index 9f81c4e..b79d8ac 100755
--- a/tools/config-clang-tidy
+++ b/tools/config-clang-tidy
@@ -29,6 +29,11 @@
)
parser_merge.set_defaults(func=subcmd_merge)
+ parser_format = subparsers.add_parser(
+ "format", help="Format a clang-tidy config"
+ )
+ parser_format.set_defaults(func=subcmd_merge)
+
parser_enable = subparsers.add_parser(
"enable", help="Enable a rule in a reference clang-tidy config"
)
@@ -50,7 +55,9 @@
def subcmd_merge(args: argparse.Namespace) -> None:
repo_path, repo_config = load_config(args.repo)
- ref_path, ref_config = load_config(args.reference)
+ _, ref_config = (
+ load_config(args.reference) if "reference" in args else ("", {})
+ )
result = {}