Require exact resolved paths for explicit help

This commit is contained in:
2026-10-20 00:23:19 +00:00
parent 7dad20680e
commit fa09edf8cc
3 changed files with 49 additions and 2 deletions

View File

@@ -161,7 +161,9 @@ func (current *execution) renderHelpTargets(targets []string) Outcome {
return Failure(errors.New("cannot render help without command metadata"))
}
route := resolveEnteredRoute(targets, snapshot)
if route.kind == routeUnknown {
// Explicit help targets are paths, not command invocations with operands.
// Discovery routes have no canonical path and retain only trailing options.
if route.kind == routeUnknown || len(route.args) != len(route.canonicalPath) {
session := internalcobra.Prepare(snapshot.metadata, current.options)
return current.app.renderHelpOutcomeWithSession(targets, current.streams, session)
}