Parse invocation flags across command discovery
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user