Commit b15dcfe
authored
refactor: improve CLI value parsing/docs (#208)
A follow-up to #204
- Allow boolean options to be treated as flags (no value passed) if
their default value is `false` (`--file-changes-only`, `--step-summary`,
`--*-review`, etc).
- Some other CLI options can now accept no value (like a flag) including
`--verbosity`
- Use `std::str::FromStr` trait to parse the given `--version`:
* if no value is given, then behave exactly like the `cpp-linter
version` subcommand (print version and exit)
* if a path is given look for clang-tools in that path. This only
ensures the given path exists, not if the clang- tool is present; that
is done later if the tool is needed.
* expand support for version specifiers using `semver::VersionReq`. This
removes the need for `lenient_semver` dependency and allows the user to
specify a range of clang versions. For example, `>=14, <16`, `=12.0.1`,
or simply `16` (would be treated as `=16`).
See [`semver::VersionReq` docs][ver-req-docs] for more detail.
- adjust docs to better describe accepted/possible values.
Due to the changes in parsing the user-given `--version`, there is a new
enum, `ClangTool` that enforces type-safety about finding the clang
tools (when they are needed).
* Instead of passing the tool name (as a str), the `ClangTool` enum is
used to avoid typos and convey explicit support for only clang-tidy and
clang-format.
* Getting the clang tool's path and version are now instance methods of
the `ClangTool` enum.
[ver-req-docs]:
https://docs.rs/semver/1.0.27/semver/struct.VersionReq.html1 parent 106a0e9 commit b15dcfe
File tree
8 files changed
+398
-198
lines changed- cpp-linter
- src
- clang_tools
- cli
- docs/src
8 files changed
+398
-198
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
356 | | - | |
| 356 | + | |
| 357 | + | |
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| |||
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
429 | 433 | | |
430 | 434 | | |
431 | 435 | | |
| |||
0 commit comments