1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! Integration tests: phd (Param Help Descriptions) + pho (Param Help Optionality).
//!
//! Bug reproducers for BUG-203 and BUG-204.
//!
//! ## Root Cause (BUG-203)
//!
//! Convenience closures `nam()`, `dry()`, `fmt()`, `thr()` in `register_commands()`
//! (src/lib.rs:120-123) create `ArgumentDefinition` objects without chaining
//! `.with_description()`. The framework renderer emits an empty description line.
//! Counterexample: `bfd()`/`bfs()` closures (lines 124-128) chain `.with_description()`
//! and their params render descriptions correctly.
//!
//! ## Why Not Caught (BUG-203)
//!
//! Existing tests validated help output structure (header, param list presence) but did
//! not assert that each parameter line includes a non-empty description string.
//! `credentials_status_help_test.rs` only covers `.credentials.status.help` params
//! which use `bfd()` — the bare closure params were never tested for description content.
//!
//! ## Fix Applied (BUG-203)
//!
//! Added `.with_description(...)` to each convenience closure in `lib.rs:120-123`:
//! `nam()`, `dry()`, `fmt()`, `thr()`. Description text sourced from canonical param
//! specs in `docs/cli/param/`.
//!
//! ## Prevention (BUG-203)
//!
//! When adding new convenience closures that register params, always chain
//! `.with_description()` — the framework emits a blank line without it, and no
//! compile-time or existing test catches the omission.
//!
//! ## Pitfall (BUG-203)
//!
//! `.with_description()` is NOT enforced by the type system. A successful `cargo build`
//! does not guarantee descriptions are present — only integration tests catching blank
//! description lines can detect the omission.
//!
//! ---
//!
//! ## Root Cause (BUG-204)
//!
//! The sole registration helper `reg_arg_opt()` at lib.rs:205-208 unconditionally calls
//! `.with_optional(None)`, marking ALL parameters as optional. `.account.use` and
//! `.account.delete` enforce `name` as required at runtime via
//! `require_nonempty_string_arg()` (commands.rs:881, 1128), but help shows `optional`.
//! No `reg_arg_req()` counterpart existed.
//!
//! ## Why Not Caught (BUG-204)
//!
//! Help output tests asserted structure but not the optionality keyword. The runtime
//! enforcement via `require_nonempty_string_arg()` masked the registration error —
//! the command correctly rejects missing `name` at runtime, so functional tests passed.
//!
//! ## Fix Applied (BUG-204)
//!
//! Added `reg_arg_req()` helper in lib.rs that calls `ArgumentDefinition::new()` without
//! `.with_optional()`, preserving the framework default `optional: false`. Changed
//! `.account.use` and `.account.delete` registrations to use `reg_arg_req("name", ...)`.
//!
//! ## Prevention (BUG-204)
//!
//! When a command enforces a param as required at runtime (`require_nonempty_string_arg`),
//! the registration must also use `reg_arg_req` — grep for `require_nonempty_string_arg`
//! and verify each site uses `reg_arg_req` in the registration vec.
//!
//! ## Pitfall (BUG-204)
//!
//! `reg_arg_opt` was the ONLY helper — adding a new command with a required param
//! naturally used `reg_arg_opt` + `nam()` because no required alternative existed.
//! The naming convention (`_opt` suffix) should have signalled the mismatch, but the
//! convenience closure `nam()` hid the optionality detail.
//!
//! ## Test Matrix
//!
//! | ID | Test Function | Condition | P/N |
//! |----|---------------|-----------|-----|
//! | phd01 | `phd01_mre_bug203_account_use_help_has_name_description` | `.account.use.help` → `name` has description | P |
//! | phd02 | `phd02_mre_bug203_account_use_help_has_dry_description` | `.account.use.help` → `dry` has description | P |
//! | phd03 | `phd03_mre_bug203_token_status_help_has_format_description` | `.token.status.help` → `format` has description | P |
//! | phd04 | `phd04_mre_bug203_token_status_help_has_threshold_description` | `.token.status.help` → `threshold` has description | P |
//! | pho01 | `pho01_mre_bug204_account_use_help_name_required` | `.account.use.help` → `name` shows `required` | P |
//! | pho02 | `pho02_mre_bug204_account_delete_help_name_required` | `.account.delete.help` → `name` shows `required` | P |
//! | pho03 | `pho03_bug204_account_relogin_help_name_optional` | `.account.relogin.help` → `name` still `optional` | P |
//! | pho04 | `pho04_bug204_accounts_help_name_optional` | `.accounts.help` → `name` still `optional` | P |
use crate;
// ── BUG-203 reproducers ─────────────────────────────────────────────────────
/// phd01: bug_reproducer(BUG-203) — `.account.use.help` shows description for `name`.
/// phd02: bug_reproducer(BUG-203) — `.account.use.help` shows description for `dry`.
/// phd03: bug_reproducer(BUG-203) — `.token.status.help` shows description for `format`.
/// phd04: bug_reproducer(BUG-203) — `.token.status.help` shows description for `threshold`.
// ── BUG-204 reproducers ─────────────────────────────────────────────────────
/// pho01: bug_reproducer(BUG-204) — `.account.use.help` shows `name` as `required`.
/// pho02: bug_reproducer(BUG-204) — `.account.delete.help` shows `name` as `required`.
/// pho03: regression guard — `.account.relogin.help` shows `name` as `optional`.
/// pho04: regression guard — `.accounts.help` shows `name` as `optional`.