Separate show cancellation from rendering errors

This commit is contained in:
2026-11-07 15:42:22 +00:00
parent 552b91c0a2
commit 4346b840db
4 changed files with 56 additions and 3 deletions

View File

@@ -66,11 +66,13 @@ func runConfigShow[I, S any](invocation commandkit.Invocation, plan *configOpera
return configFailure("Configuration show was canceled.", commandkit.Explanation{}, err)
}
var value any
var canceled error
err := reporter.RenderOutput(func(io.Writer) error {
values := make(map[string]any, len(documents))
for _, document := range documents {
if err := invocation.Context.Err(); err != nil {
return err
canceled = err
return nil
}
var native bytes.Buffer
if err := document.view.Effective.WriteEffective(&native); err != nil {
@@ -89,6 +91,9 @@ func runConfigShow[I, S any](invocation commandkit.Invocation, plan *configOpera
}
return nil
})
if canceled != nil {
return configFailure("Configuration show was canceled.", commandkit.Explanation{}, canceled)
}
if err != nil {
if canceled := invocation.Context.Err(); canceled != nil {
return configFailure("Configuration show was canceled.", commandkit.Explanation{}, canceled)