Documentation
¶
Overview ¶
Package app provides the execution context for stackit commands.
It encapsulates shared dependencies and configuration needed by actions, such as the engine instance, logger, and repository root path. This avoids passing multiple parameters throughout the application.
Index ¶
- Variables
- type Context
- func GetContext(ctx context.Context, opts GlobalOptions) (*Context, error)
- func GetContextWithWriter(ctx context.Context, opts GlobalOptions, writer io.Writer) (*Context, error)
- func NewContext(eng engine.Engine, opts ...ContextOption) *Context
- func NewContextAuto(ctx context.Context, repoRoot string, opts GlobalOptions) (*Context, error)
- func NewContextAutoWithWriter(ctx context.Context, repoRoot string, opts GlobalOptions, writer io.Writer) (*Context, error)
- func (c *Context) Absorb() engine.Absorber
- func (c *Context) Git() git.Runner
- func (c *Context) GitHub() github.Client
- func (c *Context) GitHubError() error
- func (c *Context) History() engine.StackRewriter
- func (c *Context) Info() engine.BranchInfo
- func (c *Context) Navigator() engine.StackNavigator
- func (c *Context) PR() engine.PRManager
- func (c *Context) Reader() engine.BranchReader
- func (c *Context) RemoteMetadata() engine.RemoteMetadataManager
- func (c *Context) RequireGitHub() (github.Client, error)
- func (c *Context) Status() engine.BranchStatus
- func (c *Context) Sync() engine.SyncManager
- func (c *Context) Undo() engine.UndoManager
- func (c *Context) Worktree() engine.WorktreeRegistry
- func (c *Context) Writer() engine.BranchWriter
- type ContextOption
- func WithDebug(debug bool) ContextOption
- func WithGlobalOptions(opts GlobalOptions) ContextOption
- func WithInteractive(interactive bool) ContextOption
- func WithLogger(logger output.Logger) ContextOption
- func WithQuiet(quiet bool) ContextOption
- func WithRepoRoot(repoRoot string) ContextOption
- func WithVerify(verify bool) ContextOption
- func WithWriter(writer io.Writer) ContextOption
- type GlobalOptions
Constants ¶
This section is empty.
Variables ¶
var DemoEngineFactory func() engine.Engine
DemoEngineFactory is a function that creates a demo engine. This is set by the demo package to avoid circular imports.
var DemoGitHubClientFactory func() github.Client
DemoGitHubClientFactory is a function that creates a demo GitHub client. This is set by the demo package to avoid circular imports.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
context.Context
Engine engine.Engine
Output output.Output
Logger output.Logger
RepoRoot string
GitHubClient github.Client
Config config.Configurer // Cached config to avoid repeated loading
// Global settings from flags
Interactive bool
Verify bool
Debug bool
Quiet bool
// Worktree context
InManagedWorktree bool // True if running from a stackit-managed worktree
WorktreeInfo *engine.WorktreeInfo // Info about current worktree (nil if not in managed worktree)
// contains filtered or unexported fields
}
Context provides access to engine and output for commands
func GetContext ¶
func GetContext(ctx context.Context, opts GlobalOptions) (*Context, error)
GetContext returns the appropriate context (demo or real) based on the environment. This handles git initialization and config checks for real mode.
func GetContextWithWriter ¶
func GetContextWithWriter(ctx context.Context, opts GlobalOptions, writer io.Writer) (*Context, error)
GetContextWithWriter is like GetContext but allows specifying the output writer.
func NewContext ¶
func NewContext(eng engine.Engine, opts ...ContextOption) *Context
NewContext creates a new context with the given engine and options
func NewContextAuto ¶
NewContextAuto creates a context automatically based on the environment. In demo mode, it creates a demo engine. Otherwise, it creates a real engine using the provided repoRoot.
func NewContextAutoWithWriter ¶
func NewContextAutoWithWriter(ctx context.Context, repoRoot string, opts GlobalOptions, writer io.Writer) (*Context, error)
NewContextAutoWithWriter is like NewContextAuto but allows specifying the output writer.
func (*Context) Git ¶
Git returns the git runner from the engine. Panics if the Engine is nil, which indicates a programming error.
func (*Context) GitHub ¶
GitHub returns the GitHub client, lazily initializing it on first access. If GitHubClient was set directly (e.g. in tests), it is returned immediately. Returns nil if initialization failed; use GitHubError() to get the reason.
func (*Context) GitHubError ¶
GitHubError returns the error from lazy GitHub client initialization, if any.
func (*Context) History ¶
func (c *Context) History() engine.StackRewriter
History returns the history rewriter from the engine.
func (*Context) Info ¶
func (c *Context) Info() engine.BranchInfo
Info returns the branch info provider from the engine.
func (*Context) Navigator ¶
func (c *Context) Navigator() engine.StackNavigator
Navigator returns the stack navigator from the engine.
func (*Context) Reader ¶
func (c *Context) Reader() engine.BranchReader
Reader returns the branch reader from the engine.
func (*Context) RemoteMetadata ¶
func (c *Context) RemoteMetadata() engine.RemoteMetadataManager
RemoteMetadata returns the remote metadata manager from the engine.
func (*Context) RequireGitHub ¶
RequireGitHub returns the GitHub client or an error explaining why it's unavailable. Use this instead of checking GitHub() == nil manually.
func (*Context) Status ¶
func (c *Context) Status() engine.BranchStatus
Status returns the branch status provider from the engine.
func (*Context) Sync ¶
func (c *Context) Sync() engine.SyncManager
Sync returns the sync manager from the engine.
func (*Context) Undo ¶
func (c *Context) Undo() engine.UndoManager
Undo returns the undo manager from the engine.
func (*Context) Worktree ¶
func (c *Context) Worktree() engine.WorktreeRegistry
Worktree returns the worktree registry from the engine.
func (*Context) Writer ¶
func (c *Context) Writer() engine.BranchWriter
Writer returns the branch writer from the engine.
type ContextOption ¶
type ContextOption func(*contextOptions)
ContextOption is a function that configures a Context
func WithGlobalOptions ¶
func WithGlobalOptions(opts GlobalOptions) ContextOption
WithGlobalOptions sets the global options
func WithInteractive ¶
func WithInteractive(interactive bool) ContextOption
WithInteractive sets the interactive mode
func WithRepoRoot ¶
func WithRepoRoot(repoRoot string) ContextOption
WithRepoRoot sets the repository root path
type GlobalOptions ¶
GlobalOptions holds settings from global flags
func GetDefaultGlobalOptions ¶
func GetDefaultGlobalOptions() GlobalOptions
GetDefaultGlobalOptions returns default options