Documentation
¶
Overview ¶
Package base provides the root `ofga` command: persistent flags, the help banner, and registration of every top-level sub-command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstUnknownFlag ¶
applyEnvironment resolves the color profile, theme, and output toggles from flags, environment (NO_COLOR, FORCE_COLOR, TERM=dumb) and config. FirstUnknownFlag returns the first token in args that looks like a flag but is not defined on cmd's flag set (long name or shorthand), or "" if none. Used only on the error path to disambiguate pflag swallowing an unknown flag's following token as its value (a mistyped global flag before a subcommand path otherwise surfaces as a misleading "unknown command").
Scanning stops at the first positional (non-flag) token: that positional is the intended command path, so any flag after it belongs to the (possibly mistyped) subcommand, not the root, and must not override cobra's own "unknown command" diagnosis. Known flags that take a separate value token consume that token so it isn't mistaken for the command positional.
func ForceColor ¶
func ForceColor() bool
ForceColor and ForceMono interpret the documented FORCE_COLOR variable, which colorprofile's writers ignore (they honor only CLICOLOR_FORCE). Following the widely-adopted convention (npm/chalk/supports-color), FORCE_COLOR=0/false/no/off disables color and any other non-empty value forces it on; unset is no opinion. ForceColor reports whether color is explicitly forced on.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command is the root command.
func (*Command) ErrWriter ¶
func (c *Command) ErrWriter() *colorprofile.Writer
ErrWriter returns the profile-aware writer wrapping stderr, so callers outside cobra's own output path (e.g. main's final error print) can reuse the same NO_COLOR/pipe-aware downsampling.
func (*Command) RanCommand ¶
RanCommand reports whether execution reached PersistentPreRunE, i.e. flag and argument validation passed. When it is false after Execute returns an error, the failure was a bad invocation and main exits with CodeUsage.
func (*Command) RegisterSubCommands ¶
func (c *Command) RegisterSubCommands()
RegisterSubCommands adds all top-level commands.