Documentation
¶
Overview ¶
Package cli defines flow's command tree. One file per command; this file holds the global flags and the per-invocation state every command shares.
Index ¶
- Constants
- Variables
- func Aborted(err error) bool
- func ErrorAlreadyReported(err error) bool
- func ExitCodeFor(err error) int
- func KindFor(err error) string
- func NewRootCommand() *cobra.Command
- func SetBuildInfo(version, commit, date string)
- type App
- func (a *App) Config() config.Config
- func (a *App) ConfigExists() bool
- func (a *App) ConfigPath() string
- func (a *App) DryRun() bool
- func (a *App) Editor() *editor.Launcher
- func (a *App) Git(dir string) *gitx.Git
- func (a *App) GitHub(ctx context.Context) *ghapi.Client
- func (a *App) Helm() *helmx.Helm
- func (a *App) Herdr() *herdr.CLI
- func (a *App) JSON() bool
- func (a *App) Kube() *kube.Kube
- func (a *App) ReadGit(dir string) *gitx.Git
- func (a *App) ReadHelm() *helmx.Helm
- func (a *App) ReadHerdr() *herdr.CLI
- func (a *App) Token(ctx context.Context) (string, secrets.Source)
- func (a *App) Yes() bool
- type Error
- func Dependency(format string, a ...any) *Error
- func Failure(format string, a ...any) *Error
- func NotFound(format string, a ...any) *Error
- func Precondition(format string, a ...any) *Error
- func Usage(format string, a ...any) *Error
- func Wrap(code int, kind string, err error, format string, a ...any) *Error
Constants ¶
const ( ExitOK = 0 ExitFailure = 1 ExitUsage = 2 ExitNotFound = 3 ExitPrecondition = 4 ExitDependency = 5 ExitAborted = 6 )
Exit codes. fang owns the error path, so command handlers never call os.Exit: they return an error, and main maps it through ExitCodeFor.
Variables ¶
var ( Version = "dev" Commit = "" Date = "" )
Build information, stamped by the linker via -ldflags and copied in from main before fang runs, so that `flow --version` and `flow version --json` always report the same values.
Functions ¶
func Aborted ¶
Aborted reports an error that means the user stopped the command themselves, which deserves a one-line acknowledgement rather than a styled error page.
func ErrorAlreadyReported ¶
ErrorAlreadyReported reports an error whose JSON envelope has already been written to stdout, so the terminal error handler stays silent about it.
func ExitCodeFor ¶
ExitCodeFor maps any error to flow's exit-code scheme.
func SetBuildInfo ¶
func SetBuildInfo(version, commit, date string)
SetBuildInfo records the linker-stamped values. main calls this before fang.Execute so fang's --version output and flow version agree.
Types ¶
type App ¶
type App struct {
Out *output.Renderer
Runner flowexec.Runner
Registry *registry.Store
// contains filtered or unexported fields
}
App is the state one flow invocation shares across its command. It is built lazily, so that `flow --help` never reads a config file or takes a lock.
func (*App) ConfigExists ¶
ConfigExists reports whether a config file was actually read.
func (*App) ConfigPath ¶
ConfigPath returns the resolved config file path, whether or not it exists.
func (*App) GitHub ¶
GitHub builds the GitHub client, resolving a token from the environment, the config, or the macOS keychain. A missing token is not an error: the returned client reports Unknown for everything it cannot determine.
func (*App) Kube ¶
Kube returns the kubectl wrapper. Everything flow asks kubectl is read-only, so it always uses the unwrapped runner.
type Error ¶
type Error struct {
Code int
// Kind is the machine-readable code emitted in --json mode.
Kind string
Msg string
Err error
}
Error is a flow error carrying the exit code it should produce.
func Dependency ¶
Dependency reports a missing or failing external tool.
func Precondition ¶
Precondition reports a state flow refuses to act on: a dirty worktree, an unmerged PR, the wrong kube context.