config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 6 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
	ColorCyan    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

	// 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)
}

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, 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 (*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, underlined terminal hyperlink. Falls back to plain "#N" when color is disabled.

func (*Config) Printf

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

func (*Config) Repo

func (c *Config) Repo() (repository.Repository, error)

func (*Config) Successf

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

func (*Config) Warningf

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

Jump to

Keyboard shortcuts

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