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
// LogFormat is the log format used for the logger
// Flag: --log-format [plain|json]
LogFormat log.Format
// LogLevel is the log level used for the logger
// Flag: --log-level [debug|info|warn|error]
LogLevel log.Level
// Force is used to force actions
// Flags: --force, -f
Force bool
// DryRun is used to simulate actions
// Flags: --dry-run
DryRun bool
// NoINput can be used to disable interactive mode
// Flags: --no-input
NoInput bool
// NoColor is used to control whether color is used in output
// Flags: --no-color
NoColor bool
// Quiet is used to control whether output is suppressed
// Flags: --quiet, -q
Quiet bool
// Debug is used for debugging
// Usually this implies verbose output
// Flags: --debug, -d
Debug bool
// OutputFormat is the format used for outputting data
// Flags: --plain, --json, --yaml, --markdown, etc
OutputFormat OutputFormat
// NoHeaders is used to control whether headers are printed
// Flag: --no-headers
NoHeaders bool
// contains filtered or unexported fields
}
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 ExecutionContextInput ¶
type ExecutionContextInput struct {
AppName string
ShortDescription string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Version string
}
ExecutionContextInput is used to create a new ExecutionContext
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.