Expose invocation reporting mode
This commit is contained in:
15
identity.go
15
identity.go
@@ -59,6 +59,21 @@ type Invocation struct {
|
||||
// manually constructed Invocation has no reporter.
|
||||
func (inv Invocation) Reporter() *Reporter { return inv.reporter }
|
||||
|
||||
// ReportingMode returns the selected reporting mode, independently of delivery
|
||||
// success. The selection is stable during the handler and remains available
|
||||
// after finalization. A zero Invocation returns ReportingModeOrdinary. Reads
|
||||
// are safe alongside concurrent reporting; reporting callbacks must not reenter
|
||||
// the same reporter.
|
||||
func (inv Invocation) ReportingMode() ReportingMode {
|
||||
if inv.reporter == nil || inv.reporter.state == nil {
|
||||
return ReportingModeOrdinary
|
||||
}
|
||||
state := inv.reporter.state
|
||||
state.mu.Lock()
|
||||
defer state.mu.Unlock()
|
||||
return state.mode
|
||||
}
|
||||
|
||||
// Help renders the selected command's help through this invocation's output.
|
||||
// It returns an operational failure when the invocation has no help renderer.
|
||||
func (inv Invocation) Help() Outcome {
|
||||
|
||||
Reference in New Issue
Block a user