Connect report rendering to invocation outcomes
This commit is contained in:
19
reporter.go
19
reporter.go
@@ -41,6 +41,7 @@ type reportingState struct {
|
||||
diagnostics destinationState
|
||||
closed bool
|
||||
mode reportingMode
|
||||
format Format
|
||||
progress bool
|
||||
progressSet bool
|
||||
deferred []deferredMessage
|
||||
@@ -68,10 +69,10 @@ type deferredMessage struct {
|
||||
// reenter the same reporter, and their supplied writer is valid only while the
|
||||
// callback runs.
|
||||
//
|
||||
// Consumers use Output for substantive command results and the reporting
|
||||
// methods for categorized messages. Delivery and rendering failures are
|
||||
// retained for Outcome.Presentation even when a caller ignores an immediate
|
||||
// method's returned error.
|
||||
// Consumers use Report for formatted substantive results, Output or
|
||||
// RenderOutput for deliberate raw output, and the reporting methods for
|
||||
// categorized messages. Delivery and rendering failures are retained for
|
||||
// Outcome.Presentation even when a caller ignores an immediate method's error.
|
||||
type Reporter struct {
|
||||
state *reportingState
|
||||
}
|
||||
@@ -153,6 +154,16 @@ func (w managedOutputWriter) Write(p []byte) (int, error) {
|
||||
return w.state.write(w.destination, p)
|
||||
}
|
||||
|
||||
// Report renders and delivers substantive content using the invocation's
|
||||
// selected format. Rendering runs even when output is suppressed, and its
|
||||
// failures are recorded separately from the operation outcome. Report must
|
||||
// not be called from a rendering callback on the same reporter.
|
||||
func (r *Reporter) Report(report Report) error {
|
||||
return r.RenderOutput(func(w io.Writer) error {
|
||||
return RenderReport(w, report, r.state.format)
|
||||
})
|
||||
}
|
||||
|
||||
// RenderOutput coordinates a complete substantive report rendering operation.
|
||||
// The callback receives a writer usable only during the callback and must not
|
||||
// reenter this reporter. In quiet mode, the callback still runs against a
|
||||
|
||||
Reference in New Issue
Block a user