Use native configuration views and shared prompt loading

This commit is contained in:
2026-11-23 03:28:30 +00:00
parent b6693fde73
commit 5e29399705
6 changed files with 49 additions and 130 deletions

View File

@@ -1,40 +1,15 @@
package cli
import (
"context"
"go.maximumdirect.net/ckprompt"
"go.maximumdirect.net/commandkit"
"go.maximumdirect.net/promptkit"
)
func promptSuite() ckprompt.Suite[applicationInput, *acquisitionState] {
func promptSuite() ckprompt.Suite[applicationInput, struct{}] {
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)
}
return ckprompt.WithNamespaces(suite, promptkit.Namespaces{})
}