Documentation
¶
Overview ¶
Package commands holds the Cobra commands. Each command parses flags, calls the API client through the runtime, and renders; nothing here talks HTTP or the terminal directly.
Index ¶
Constants ¶
const EnvNoUpdateNotifier = "WANIIS_NO_UPDATE_NOTIFIER"
EnvNoUpdateNotifier turns the daily "a new version is available" line off.
Variables ¶
var ( Version = "dev" Commit = "none" Date = "unknown" )
Build information, set by the linker (GoReleaser).
Functions ¶
Types ¶
type Deps ¶
type Deps struct {
In io.Reader
Out io.Writer
Err io.Writer
Getenv func(string) string
HTTP *http.Client
Store auth.Store
// OpenBrowser opens a URL; it returns an error when it can't.
OpenBrowser func(url string) error
Sleep func(context.Context, time.Duration) error
Now func() time.Time
NewKey func() string
// StdinTTY and StdoutTTY say whether the streams are terminals.
StdinTTY, StdoutTTY bool
// GitOrigin returns the `origin` remote URL of the current checkout, or "".
GitOrigin func() string
Hostname func() string
// PollInterval is how often --wait checks the session.
PollInterval time.Duration
// MakeRaw puts the terminal's input in raw mode for the interactive chat and returns the
// function that restores it. Nil: the chat reads plain lines.
MakeRaw func() (restore func(), err error)
// TermWidth is the terminal's width in columns; nil or 0 means 80.
TermWidth func() int
// RetryDelay overrides the API client's base retry delay when non-zero.
RetryDelay time.Duration
// ConfigDir is where the CLI keeps its files (the daily version check); "" turns the check off.
ConfigDir string
// Executable is the running binary's path, symlinks resolved; nil uses the real one.
Executable func() (string, error)
// RunCommand runs a program with the CLI's output (brew); nil runs it for real.
RunCommand func(ctx context.Context, name string, args ...string) error
// ReleasesAPI is GitHub's releases API for the CLI; "" is the real one.
ReleasesAPI string
}
Deps is everything the commands need from the outside world, so tests can replace it.