diff --git a/cpp_linter_hooks/clang_format.py b/cpp_linter_hooks/clang_format.py index e5cf240..d390651 100644 --- a/cpp_linter_hooks/clang_format.py +++ b/cpp_linter_hooks/clang_format.py @@ -7,7 +7,14 @@ from cpp_linter_hooks.util import resolve_install_with_diagnostics parser = ArgumentParser() -parser.add_argument("--version", default=None) +parser.add_argument( + "--version", + default=None, + help=( + "Version of clang-format to install and run; defaults to the latest " + "stable wheel on PyPI" + ), +) parser.add_argument( "-v", "--verbose", action="store_true", help="Enable verbose output" ) diff --git a/cpp_linter_hooks/clang_tidy.py b/cpp_linter_hooks/clang_tidy.py index 5b1c8f7..92bcebb 100644 --- a/cpp_linter_hooks/clang_tidy.py +++ b/cpp_linter_hooks/clang_tidy.py @@ -52,13 +52,36 @@ def _positive_int(value: str) -> int: parser = ArgumentParser() -parser.add_argument("--version", default=None) -parser.add_argument("--compile-commands", default=None, dest="compile_commands") parser.add_argument( - "--no-compile-commands", action="store_true", dest="no_compile_commands" + "--version", + default=None, + help=( + "Version of clang-tidy to install and run; defaults to the latest stable " + "wheel on PyPI" + ), +) +parser.add_argument( + "--compile-commands", + default=None, + dest="compile_commands", + help="Directory containing compile_commands.json to pass to clang-tidy via -p", +) +parser.add_argument( + "--no-compile-commands", + action="store_true", + dest="no_compile_commands", + help="Disable automatic compile_commands.json detection", +) +parser.add_argument( + "-j", + "--jobs", + type=_positive_int, + default=1, + help="Number of clang-tidy processes to run in parallel (default: 1)", +) +parser.add_argument( + "-v", "--verbose", action="store_true", help="Enable verbose output" ) -parser.add_argument("-j", "--jobs", type=_positive_int, default=1) -parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("--fix", action="store_true", help="Apply fixes in place (-fix)") diff --git a/tests/test_clang_format.py b/tests/test_clang_format.py index dae5c2a..929d9d6 100644 --- a/tests/test_clang_format.py +++ b/tests/test_clang_format.py @@ -3,7 +3,17 @@ import pytest -from cpp_linter_hooks.clang_format import main, run_clang_format +from cpp_linter_hooks.clang_format import main, parser, run_clang_format + + +def test_all_arguments_have_help(): + missing_help = [ + action.option_strings for action in parser._actions if not action.help + ] + assert missing_help == [] + + help_text = " ".join(parser.format_help().split()) + assert all(" ".join(action.help.split()) in help_text for action in parser._actions) @pytest.mark.benchmark diff --git a/tests/test_clang_tidy.py b/tests/test_clang_tidy.py index f112db2..4522f36 100644 --- a/tests/test_clang_tidy.py +++ b/tests/test_clang_tidy.py @@ -5,7 +5,17 @@ import pytest -from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, run_clang_tidy +from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, parser, run_clang_tidy + + +def test_all_arguments_have_help(): + missing_help = [ + action.option_strings for action in parser._actions if not action.help + ] + assert missing_help == [] + + help_text = " ".join(parser.format_help().split()) + assert all(" ".join(action.help.split()) in help_text for action in parser._actions) @pytest.fixture(scope="function")