Connect invocation execution to one reporter

This commit is contained in:
2026-10-26 02:59:28 +00:00
parent df21b75f9c
commit 49a10690c6
6 changed files with 261 additions and 144 deletions

View File

@@ -37,20 +37,22 @@ func normalizeStreams(streams Streams) Streams {
return streams
}
// Invocation provides execution context and output streams to a command
// handler. For command aliases, EnteredPath and CanonicalPath expose the route
// the caller used and the selected canonical command path. Both omit the
// Invocation provides execution context and reporting to a command handler.
// For command aliases, EnteredPath and CanonicalPath expose the route the
// caller used and the selected canonical command path. Both omit the
// executable name, flags, and operands.
type Invocation struct {
// Context carries caller cancellation and request-scoped values.
Context context.Context
// Streams are the caller-selected output destinations.
Streams Streams
reporter *Reporter
enteredPath string
canonicalPath string
}
// Reporter returns the reporting facility for this invocation.
func (inv Invocation) Reporter() *Reporter { return inv.reporter }
// EnteredPath returns the command path used to invoke the selected command,
// excluding the executable name, flags, and operands. It is empty for an
// Invocation that was not created by command execution.