Commit d27c20b
test: prevent duplicated aliases from idiots (#365)
* fix(usage_md): detect and reject visible aliases that duplicate their own flag name
A visible_alias matching the argument's own --long name (or a
visible_short_alias matching its -short flag) is a coding mistake that
produces redundant output in USAGE.md. The new validation runs at the
start of render_usage_md() and exits with code 1 if any such
redundancy is found.
https://claude.ai/code/session_01TSnvxN1HBwwzhxfFShWAQ5
* refactor(usage_md): return custom error type instead of calling process::exit
Define a non-exhaustive `RenderUsageMdError` enum with
`derive_more::{Display, Error}` and make `render_usage_md` return
`Result<String, RenderUsageMdError>`. The callsites in cli/usage_md.rs
and tests/sync_usage_md.rs now handle the error appropriately.
https://claude.ai/code/session_01TSnvxN1HBwwzhxfFShWAQ5
* refactor(usage_md): address review feedback on error type and callsites
- Split RedundantVisibleAlias into RedundantVisibleLongAlias(String)
and RedundantVisibleShortAlias(char), moving message into #[display]
- Rename validate_no_redundant_visible_aliases to check_visible_aliases
- Use if-let-Err pattern in cli/usage_md.rs to match lib.rs style
- Simplify test to use .unwrap() instead of .expect()
- Fix doc comment to use plain English instead of backtick-wrapped flags
https://claude.ai/code/session_01TSnvxN1HBwwzhxfFShWAQ5
* refactor(usage_md): rename to reject_redundant_aliases, use pipe-trait, revert to match
- Rename check_visible_aliases to reject_redundant_aliases
- Use pipe-trait to flatten nested constructor and Err calls
- Revert cli/usage_md.rs back to match pattern
https://claude.ai/code/session_01TSnvxN1HBwwzhxfFShWAQ5
* refactor(usage_md): return ExitCode instead of calling process::exit
https://claude.ai/code/session_01TSnvxN1HBwwzhxfFShWAQ5
* docs: improve error message
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 618b701 commit d27c20b
3 files changed
Lines changed: 64 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
5 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
7 | 21 | | |
8 | | - | |
| 22 | + | |
9 | 23 | | |
| 24 | + | |
10 | 25 | | |
11 | 26 | | |
12 | 27 | | |
| |||
59 | 74 | | |
60 | 75 | | |
61 | 76 | | |
62 | | - | |
| 77 | + | |
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
| |||
232 | 247 | | |
233 | 248 | | |
234 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
0 commit comments