Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecutionContext ¶
type ExecutionContext struct {
// AppName is the executable app name
// Keep it in lower case letters and use dashes for multi-word app names
AppName string
// ShortDescription is a short description of the app
ShortDescription string
// LongDescription is a long description of the app
LongDescription string
// Stdin is the input stream
Stdin io.Reader
// Stdout is the output stream
Stdout io.Writer
// Stderr is the error stream
Stderr io.Writer
// Command is the current command
Command *cobra.Command
// Logger is the global logger
Logger *slog.Logger
// ErrorHandler
ErrorHandler errors.Handler
// Spinner is the global spinner object used to show progress across the cli
Spinner ui.Spinner
// IsTerminal indicates whether the current session is a terminal or not
IsTerminal bool
// Version is the CLI version
// Flag: --version
Version string
// PFlags are the persistent flag configuration
PFlags PFlags
// OutputFormat is the format used for outputting data
// Flags: --plain, --json, --yaml, --markdown, etc
OutputFormat OutputFormat
// for changing log level
LogLevel *slog.LevelVar
}
ExecutionContext holds configuration that can be used (and modified) across the application
func NewExecutionContext ¶
func NewExecutionContext(appName, shortDesc, version string, stdin io.Reader, stdout, stderr io.Writer) *ExecutionContext
NewExecutionContext creates a new ExecutionContext
func (*ExecutionContext) SetColor ¶
func (ec *ExecutionContext) SetColor(noColor bool)
SetColor sets weather color should be used in the output If the output is not a terminal, color is disabled If the --no-color flag is set, color is disabled If the --no-input flag is set, color is disabled
func (*ExecutionContext) SetLogLevel ¶
func (ec *ExecutionContext) SetLogLevel()
SetLogLevel sets the ec.Logger log level
type OutputFormat ¶
type OutputFormat string
const ( OutputFormatPlain OutputFormat = "plain" OutputFormatJSON OutputFormat = "json" OutputFormatYAML OutputFormat = "yaml" OutputFormatMarkdown OutputFormat = "markdown" )
func (OutputFormat) String ¶
func (o OutputFormat) String() string
Click to show internal directories.
Click to hide internal directories.