Commit 8ac69d1
fix(main): surface invalid-subcommand hint in agent --help
In agent mode, `--help` is intercepted before clap to emit a JSON
schema. The intercept resolved the requested subcommand and fell
through a catch-all to the generic root schema (exit 0) whenever it
didn't resolve — swallowing clap's "did you mean" suggestion. So
`pup monitor list --help --agent` was less helpful than the same
command without `--help`.
Only emit a schema when the request resolves to a real command (or
no subcommand was given); for an unknown subcommand, fall through to
clap so it reports the typo with a suggestion.
- Make `find_subcommand` alias-aware so valid aliases (e.g. `audit`)
still return the scoped JSON schema instead of clap text help.
- Extract `top_level_subcommand` to skip values of value-taking global
flags (`--org`, `-o/--output`, `--jq`), so `--org x monitors --help`
scopes to `monitors`, not the flag value.
- Add unit tests for subcommand resolution, alias handling, and
top-level extraction.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 490c829 commit 8ac69d1
2 files changed
Lines changed: 166 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10896 | 10896 | | |
10897 | 10897 | | |
10898 | 10898 | | |
| 10899 | + | |
| 10900 | + | |
| 10901 | + | |
| 10902 | + | |
| 10903 | + | |
| 10904 | + | |
| 10905 | + | |
| 10906 | + | |
| 10907 | + | |
| 10908 | + | |
| 10909 | + | |
| 10910 | + | |
| 10911 | + | |
| 10912 | + | |
| 10913 | + | |
| 10914 | + | |
| 10915 | + | |
| 10916 | + | |
| 10917 | + | |
| 10918 | + | |
| 10919 | + | |
| 10920 | + | |
| 10921 | + | |
| 10922 | + | |
| 10923 | + | |
10899 | 10924 | | |
10900 | 10925 | | |
10901 | 10926 | | |
10902 | | - | |
| 10927 | + | |
| 10928 | + | |
| 10929 | + | |
| 10930 | + | |
| 10931 | + | |
10903 | 10932 | | |
10904 | 10933 | | |
10905 | 10934 | | |
| |||
12283 | 12312 | | |
12284 | 12313 | | |
12285 | 12314 | | |
12286 | | - | |
12287 | | - | |
12288 | | - | |
12289 | | - | |
12290 | | - | |
12291 | | - | |
12292 | | - | |
12293 | | - | |
12294 | | - | |
| 12315 | + | |
| 12316 | + | |
12295 | 12317 | | |
12296 | | - | |
12297 | | - | |
12298 | | - | |
| 12318 | + | |
| 12319 | + | |
| 12320 | + | |
| 12321 | + | |
| 12322 | + | |
| 12323 | + | |
| 12324 | + | |
| 12325 | + | |
| 12326 | + | |
| 12327 | + | |
12299 | 12328 | | |
12300 | | - | |
12301 | | - | |
12302 | | - | |
12303 | | - | |
| 12329 | + | |
| 12330 | + | |
| 12331 | + | |
| 12332 | + | |
| 12333 | + | |
| 12334 | + | |
| 12335 | + | |
| 12336 | + | |
12304 | 12337 | | |
12305 | 12338 | | |
12306 | 12339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1165 | 1165 | | |
1166 | 1166 | | |
1167 | 1167 | | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
0 commit comments