Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Terminal term.Term
	Out      *os.File
	Err      *os.File
	In       *os.File

	ColorSuccess func(string) string
	ColorError   func(string) string
	ColorWarning func(string) string
	ColorBold    func(string) string
	ColorBlue    func(string) string
	ColorMagenta func(string) string
	ColorAccent  func(string) string
	ColorGray    func(string) string

	// GitHubClientOverride, when non-nil, is returned by GitHubClient()
	// instead of creating a real client. Used in tests to inject a MockClient.
	GitHubClientOverride ghapi.ClientOps

	// ForceInteractive, when true, makes IsInteractive() return true
	// regardless of the terminal state. Used in tests.
	ForceInteractive bool

	// NonInteractive suppresses prompts even when stdout is a terminal.
	NonInteractive bool

	// Canceled records explicit user cancellation even when a command returns ErrSilent.
	Canceled bool

	// WorktreePathOnly makes checkout resolution skip imports for foreign owners.
	WorktreePathOnly bool

	// StackMutation is command-lifetime coordination, never persisted.
	StackMutation *StackMutationContext

	// SelectFn, when non-nil, is called instead of prompting via the
	// terminal. Used in tests to simulate interactive selection.
	SelectFn func(prompt, defaultValue string, options []string) (int, error)

	// ConfirmFn, when non-nil, is called instead of prompting via the
	// terminal. Used in tests to simulate yes/no confirmation prompts.
	ConfirmFn func(prompt string, defaultValue bool) (bool, error)

	// InputFn, when non-nil, is called instead of prompting via the
	// terminal. Used in tests to simulate text input prompts.
	InputFn func(prompt string) (string, error)

	// RepoOverride, when non-nil, is returned by Repo() instead of
	// calling repository.Current(). Used in tests to avoid depending on
	// the real git repo context.
	RepoOverride *repository.Repository
}

Config holds shared state for all commands.

func New

func New() *Config

New creates a new Config with terminal-aware output and color support.

func NewTestConfig

func NewTestConfig() (*Config, *os.File, *os.File)

NewTestConfig creates a Config suitable for testing with captured output buffers. Color functions are no-ops, GitHub calls are stubbed, and the config is non-interactive.

func (*Config) Errorf

func (c *Config) Errorf(format string, args ...any)

func (*Config) GitHubClient

func (c *Config) GitHubClient() (ghapi.ClientOps, error)

func (*Config) Infof

func (c *Config) Infof(format string, args ...any)

func (*Config) IsInteractive

func (c *Config) IsInteractive() bool
func (c *Config) Link(label, url string) string

Link formats a reference with a terminal hyperlink or a copyable URL fallback.

func (*Config) Outf

func (c *Config) Outf(format string, args ...any)
func (c *Config) PRLink(number int, url string) string

PRLink formats a PR number as a clickable terminal hyperlink when supported, or includes the full URL as a copyable fallback.

func (*Config) Printf

func (c *Config) Printf(format string, args ...any)

func (*Config) Repo

func (c *Config) Repo() (repository.Repository, error)
func (c *Config) StackLink(number int) string

StackLink formats a stack number using the same conventions as PRLink.

func (*Config) StackURL added in v0.3.0

func (c *Config) StackURL(number int) string

StackURL returns no destination when optional display identity is unavailable. Formatting a reference must not turn an otherwise successful command into an error.

func (*Config) Successf

func (c *Config) Successf(format string, args ...any)
func (c *Config) TerminalLink(label, url string) string

TerminalLink keeps a compact label when terminal hyperlinks are unavailable. Use Link's raw underline codes; per-rune TUI underlining can corrupt OSC 8.

func (*Config) Warningf

func (c *Config) Warningf(format string, args ...any)

type StackMutationContext added in v0.2.0

type StackMutationContext struct {
	CommonDir string
	StateDir  string

	// NoCheckoutOnSelect preserves rewrite origins and range anchors.
	NoCheckoutOnSelect bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL