Honor help-only input checks before starting features

This commit is contained in:
2026-11-22 22:21:32 +00:00
parent 362afc79b6
commit 98e3958dfb
8 changed files with 121 additions and 15 deletions

View File

@@ -93,10 +93,13 @@ func (current *execution) prepareFeatures(parsed commandmeta.Result, required bo
if offset+count > len(parsed.InvocationFlagValues) || offset+count > len(parsed.InvocationFlagSpellings) {
return fmt.Errorf("missing invocation feature flag values")
}
start, err := feature.payload.prepare(parsed.InvocationFlagValues[offset:offset+count], parsed.InvocationFlagSpellings[offset:offset+count], parsed.FlagOccurrences, required)
start, err := feature.payload.prepare(parsed.InvocationFlagValues[offset:offset+count], parsed.InvocationFlagSpellings[offset:offset+count], parsed.FlagOccurrences, false)
if err != nil {
return err
}
if required && current.featureRequiredError == nil {
current.featureRequiredError = feature.payload.requiredError(parsed.InvocationFlagValues[offset : offset+count])
}
current.featureStarts = append(current.featureStarts, start)
offset += count
}
@@ -104,16 +107,17 @@ func (current *execution) prepareFeatures(parsed commandmeta.Result, required bo
}
type execution struct {
app *App
ctx context.Context
reporter *Reporter
featureStarts []func(Invocation) (context.Context, func() Report)
featureEnabled bool
featureReports []func() Report
debugEvents []string
snapshot *routingSnapshot
session *internalcobra.Session
route routeResult
app *App
ctx context.Context
reporter *Reporter
featureStarts []func(Invocation) (context.Context, func() Report)
featureRequiredError error
featureEnabled bool
featureReports []func() Report
debugEvents []string
snapshot *routingSnapshot
session *internalcobra.Session
route routeResult
}
func (current *execution) startFeatures() {