Parse invocation flags across command discovery

This commit is contained in:
2026-11-22 20:53:25 +00:00
parent ea3ce25001
commit b6cb183a71
10 changed files with 136 additions and 30 deletions

View File

@@ -23,6 +23,7 @@ type InvocationFeatureSpec[I any] struct {
type invocationFeaturePayload interface {
bridgeFlags() []commandmeta.Flag
prepare([][]string, [][]string, []commandmeta.FlagOccurrence, bool) (func(Invocation) (context.Context, func() Report), error)
}
type typedInvocationFeature[I any] struct{ spec InvocationFeatureSpec[I] }
@@ -31,6 +32,14 @@ func (f typedInvocationFeature[I]) bridgeFlags() []commandmeta.Flag {
return (typedCommand[I]{spec: CommandSpec[I]{Flags: f.spec.Flags}}).bridgeFlags()
}
func (f typedInvocationFeature[I]) prepare(values, spellings [][]string, occurrences []commandmeta.FlagOccurrence, required bool) (func(Invocation) (context.Context, func() Report), error) {
input, err := prepareInputWithOccurrences(CommandSpec[I]{NewInput: f.spec.NewInput, Flags: f.spec.Flags}, values, spellings, occurrences, nil, required)
if err != nil {
return nil, err
}
return func(inv Invocation) (context.Context, func() Report) { return f.spec.Start(inv, input.build()) }, nil
}
type invocationFeatureRecord struct {
payload invocationFeaturePayload
issues []error