41 lines
2.0 KiB
Go
41 lines
2.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.maximumdirect.net/ckprompt"
|
|
"go.maximumdirect.net/commandkit"
|
|
"go.maximumdirect.net/promptkit"
|
|
)
|
|
|
|
func promptSuite() ckprompt.Suite[applicationInput, *acquisitionState] {
|
|
suite := ckprompt.FromEngine(loadEngine)
|
|
suite.NewInput = func() applicationInput { return applicationInput{} }
|
|
suite.NewState = func() *acquisitionState { return &acquisitionState{} }
|
|
suite = ckprompt.WithRequestValidation(suite, loadEngine, nil)
|
|
suite = ckprompt.WithRequestPreparation(suite, loadEngine, nil)
|
|
suite = ckprompt.WithSmokeTesting(suite, loadEngine, nil)
|
|
suite = ckprompt.WithNamespaces(suite, promptkit.Namespaces{})
|
|
suite.ListPrompts = withApplicationEvidence(suite.ListPrompts)
|
|
suite.ListProfiles = withApplicationEvidence(suite.ListProfiles)
|
|
suite.ListBackends = withApplicationEvidence(suite.ListBackends)
|
|
suite.ListNamespaces = withApplicationEvidence(suite.ListNamespaces)
|
|
suite.ListCollections = withApplicationEvidence(suite.ListCollections)
|
|
suite.InspectPrompt = withApplicationEvidence(suite.InspectPrompt)
|
|
suite.InspectProfile = withApplicationEvidence(suite.InspectProfile)
|
|
suite.InspectBackend = withApplicationEvidence(suite.InspectBackend)
|
|
suite.InspectRequirements = withApplicationEvidence(suite.InspectRequirements)
|
|
suite.ValidateRequest = withApplicationEvidence(suite.ValidateRequest)
|
|
suite.PrepareRequest = withApplicationEvidence(suite.PrepareRequest)
|
|
suite.SmokeTest = withApplicationEvidence(suite.SmokeTest)
|
|
return suite
|
|
}
|
|
|
|
func withApplicationEvidence[R, V any](callback func(context.Context, R, applicationInput, *acquisitionState) (commandkit.Acquired[V], error)) func(context.Context, R, applicationInput, *acquisitionState) (commandkit.Acquired[V], error) {
|
|
return func(ctx context.Context, request R, input applicationInput, state *acquisitionState) (commandkit.Acquired[V], error) {
|
|
start := state.mark()
|
|
acquired, err := callback(ctx, request, input, state)
|
|
return attachApplicationEvidence(acquired, err, state, start, false)
|
|
}
|
|
}
|