Skip to content

Commit 05fa3a4

Browse files
authored
docs: add missing CLI help text (#278)
1 parent 1a33baa commit 05fa3a4

4 files changed

Lines changed: 58 additions & 8 deletions

File tree

‎cpp_linter_hooks/clang_format.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
from cpp_linter_hooks.util import resolve_install_with_diagnostics
88

99
parser = ArgumentParser()
10-
parser.add_argument("--version", default=None)
10+
parser.add_argument(
11+
"--version",
12+
default=None,
13+
help=(
14+
"Version of clang-format to install and run; defaults to the latest "
15+
"stable wheel on PyPI"
16+
),
17+
)
1118
parser.add_argument(
1219
"-v", "--verbose", action="store_true", help="Enable verbose output"
1320
)

‎cpp_linter_hooks/clang_tidy.py‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,36 @@ def _positive_int(value: str) -> int:
5252

5353

5454
parser = ArgumentParser()
55-
parser.add_argument("--version", default=None)
56-
parser.add_argument("--compile-commands", default=None, dest="compile_commands")
5755
parser.add_argument(
58-
"--no-compile-commands", action="store_true", dest="no_compile_commands"
56+
"--version",
57+
default=None,
58+
help=(
59+
"Version of clang-tidy to install and run; defaults to the latest stable "
60+
"wheel on PyPI"
61+
),
62+
)
63+
parser.add_argument(
64+
"--compile-commands",
65+
default=None,
66+
dest="compile_commands",
67+
help="Directory containing compile_commands.json to pass to clang-tidy via -p",
68+
)
69+
parser.add_argument(
70+
"--no-compile-commands",
71+
action="store_true",
72+
dest="no_compile_commands",
73+
help="Disable automatic compile_commands.json detection",
74+
)
75+
parser.add_argument(
76+
"-j",
77+
"--jobs",
78+
type=_positive_int,
79+
default=1,
80+
help="Number of clang-tidy processes to run in parallel (default: 1)",
81+
)
82+
parser.add_argument(
83+
"-v", "--verbose", action="store_true", help="Enable verbose output"
5984
)
60-
parser.add_argument("-j", "--jobs", type=_positive_int, default=1)
61-
parser.add_argument("-v", "--verbose", action="store_true")
6285
parser.add_argument("--fix", action="store_true", help="Apply fixes in place (-fix)")
6386

6487

‎tests/test_clang_format.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33

44
import pytest
55

6-
from cpp_linter_hooks.clang_format import main, run_clang_format
6+
from cpp_linter_hooks.clang_format import main, parser, run_clang_format
7+
8+
9+
def test_all_arguments_have_help():
10+
missing_help = [
11+
action.option_strings for action in parser._actions if not action.help
12+
]
13+
assert missing_help == []
14+
15+
help_text = " ".join(parser.format_help().split())
16+
assert all(" ".join(action.help.split()) in help_text for action in parser._actions)
717

818

919
@pytest.mark.benchmark

‎tests/test_clang_tidy.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55

66
import pytest
77

8-
from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, run_clang_tidy
8+
from cpp_linter_hooks.clang_tidy import _exec_clang_tidy, parser, run_clang_tidy
9+
10+
11+
def test_all_arguments_have_help():
12+
missing_help = [
13+
action.option_strings for action in parser._actions if not action.help
14+
]
15+
assert missing_help == []
16+
17+
help_text = " ".join(parser.format_help().split())
18+
assert all(" ".join(action.help.split()) in help_text for action in parser._actions)
919

1020

1121
@pytest.fixture(scope="function")

0 commit comments

Comments
 (0)