Connect invocation execution to one reporter
This commit is contained in:
26
reporter.go
26
reporter.go
@@ -5,6 +5,8 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
commandmeta "gitea.maximumdirect.net/eric/CommandKit/internal/commandmeta"
|
||||
)
|
||||
|
||||
type reportingMode uint8
|
||||
@@ -100,6 +102,30 @@ func newReporter(streams Streams) *Reporter {
|
||||
}}
|
||||
}
|
||||
|
||||
func (r *Reporter) applySelection(selection commandmeta.ReportingSelection) {
|
||||
if r == nil || r.state == nil {
|
||||
return
|
||||
}
|
||||
state := r.state
|
||||
state.mu.Lock()
|
||||
defer state.mu.Unlock()
|
||||
if state.closed {
|
||||
return
|
||||
}
|
||||
switch selection.Mode {
|
||||
case commandmeta.ReportingModeQuiet:
|
||||
state.mode = modeQuiet
|
||||
case commandmeta.ReportingModeVerbose:
|
||||
state.mode = modeVerbose
|
||||
case commandmeta.ReportingModeDebug:
|
||||
state.mode = modeDebug
|
||||
default:
|
||||
state.mode = modeOrdinary
|
||||
}
|
||||
state.progress = selection.Progress
|
||||
state.progressSet = selection.ProgressSet
|
||||
}
|
||||
|
||||
// Output returns a managed writer for substantive command results.
|
||||
func (r *Reporter) Output() io.Writer {
|
||||
if r == nil || r.state == nil {
|
||||
|
||||
Reference in New Issue
Block a user