Documentation
¶
Index ¶
- Constants
- func ExpandRef(ctx *Context, ref executable.Ref) executable.Ref
- func ExpandRefFromParent(parent *executable.Executable, ref executable.Ref) executable.Ref
- type Context
- func (ctx *Context) AddCallback(callback func(*Context) error)
- func (ctx *Context) AppName() string
- func (ctx *Context) Cancel()
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) Finalize()
- func (ctx *Context) SetContext(c context.Context, cancelFunc context.CancelFunc)
- func (ctx *Context) SetIO(stdIn, stdOut *os.File)
- func (ctx *Context) SetStdErr(stdErr *os.File)
- func (ctx *Context) SetTUIContainer(c *tuikit.Container)
- func (ctx *Context) SetView(view tuikit.View) error
- func (ctx *Context) ShallowCopy() *Context
- func (ctx *Context) StdErr() *os.File
- func (ctx *Context) StdIn() *os.File
- func (ctx *Context) StdOut() *os.File
- func (ctx *Context) String() string
- func (ctx *Context) TUIContainer() *tuikit.Container
- func (ctx *Context) Value(key any) any
- type Option
Constants ¶
const HeaderCtxKey = "ctx"
Variables ¶
This section is empty.
Functions ¶
func ExpandRef ¶
func ExpandRef(ctx *Context, ref executable.Ref) executable.Ref
func ExpandRefFromParent ¶
func ExpandRefFromParent(parent *executable.Executable, ref executable.Ref) executable.Ref
Types ¶
type Context ¶
type Context struct {
Config *config.Config
CurrentWorkspace *workspace.Workspace
WorkspacesCache cache.WorkspaceCache
ExecutableCache cache.ExecutableCache
DataStore store.DataStore
// RootExecutable is the executable that is being run in the current context.
// This will be nil if the context is not associated with an executable run.
RootExecutable *executable.Executable
// ProcessTmpDir is the temporary directory for the current process. If set, it will be
// used to store temporary files all executable runs when the tmpDir value is specified.
ProcessTmpDir string
// CurrentTask holds the task context for the currently executing step in a
// parallel or serial runner. It is set per-goroutine (via shallow copy) so
// that downstream writers can prefix output with the task name.
CurrentTask *io.TaskContext
// LogArchiveID is the unique identifier used in the log archive filename for
// this process. It is set at startup and used to link execution records to
// their log output.
LogArchiveID string
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) AddCallback ¶
func (*Context) SetContext ¶
func (ctx *Context) SetContext(c context.Context, cancelFunc context.CancelFunc)
SetContext sets the context and cancel function for the Context. This function should NOT be used outside of tests! The context and cancel function should be set when creating the context.
func (*Context) SetIO ¶
SetIO sets the standard input and output for the context This function should NOT be used outside of tests! The standard input and output should be set when creating the context.
func (*Context) SetTUIContainer ¶
SetTUIContainer sets the TUI container directly, bypassing lazy init. This is intended for tests that provide a pre-built container.
func (*Context) ShallowCopy ¶
ShallowCopy returns a pointer to a new Context that shares all backing state (config, caches, data store, TUI container) but has its own mutable fields (CurrentTask, ProcessTmpDir, etc.)
func (*Context) StdErr ¶
StdErr returns the standard error file for structured error envelopes. Falls back to os.Stderr when unset (e.g. in tests that bypass NewContext).
func (*Context) TUIContainer ¶
TUIContainer returns the TUI container, initializing it on first access. This avoids eagerly creating a bubbletea program (which reads terminal state from stdin) for commands that never use the TUI.
type Option ¶
type Option func(*Context)
Option configures optional fields on a Context during construction.
func WithAppName ¶
func WithStdErr ¶
WithStdErr sets the standard error file. Defaults to os.Stderr.
func WithStdOut ¶
WithStdOut sets the standard output file. Defaults to os.Stdout.