{"modulePath":"github.com/c3xdev/c3x","version":"v1.0.2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cli\n\n## Variables\n\n```go\nvar (\n\t// AppVersionTemplate is the text template for the Default version topic.\n\tAppVersionTemplate = \"\"\n\n\t// AppHelpTemplate is the text template for the Default help topic.\n\tAppHelpTemplate = \"\"\n\n\t// CommandHelpTemplate is the text template for the command help topic.\n\tCommandHelpTemplate = \"\"\n)\n```\n\n```go\nvar (\n\tMapFlagEnvVarSep = \",\"\n\tMapFlagKeyValSep = \"=\"\n)\n```\n\n```go\nvar (\n\t// FlagSplitter uses to separate arguments and env vars with multiple values.\n\tFlagSplitter = strings.Split\n)\n```\n\n```go\nvar (\n\tSliceFlagEnvVarSep = \",\"\n)\n```\n\n## Functions\n\n```go\nfunc LexicographicLess(i, j string) bool\n```\nLexicographicLess compares strings alphabetically considering case.\n\n```go\nfunc NewExitError(message interface{}, exitCode int) cli.ExitCoder\n```\nNewExitError calls Exit to create a new ExitCoder.\n\nDeprecated: This function is a duplicate of Exit and will eventually be removed.\n\n```go\nfunc ShowAppHelp(ctx *Context) error\n```\nShowAppHelp prints App help.\n\n```go\nfunc ShowCommandHelp(ctx *Context, cmdName string) error\n```\nShowCommandHelp prints help for the given command.\n\n```go\nfunc ShowVersion(ctx *Context) error\n```\n\n## Types\n\n```go\ntype ActionFunc func(*Context) error\n```\nActionFunc is the action to execute when no commands/subcommands are specified.\n\n```go\ntype ActionableFlag interface {\n\tFlag\n\tRunAction(*Context) error\n}\n```\nActionableFlag is an interface that wraps Flag interface and RunAction operation.\n\n```go\ntype App struct {\n\t*cli.App\n\t// List of commands to execute\n\tCommands Commands\n\t// List of flags to parse\n\tFlags Flags\n\t// CustomAppVersionTemplate text template for app version topic.\n\tCustomAppVersionTemplate string\n\t// Contributor\n\tAuthor string\n\t// An action to execute before running the `Action` of the target command.\n\t// The difference between `Before` is that `CommonBefore` runs only once for the target command, while `Before` is different for each command and is performed by each command.\n\t// Useful when some steps need to to performed for all commands without exception, when all flags are parsed and the context contains the target command.\n\tCommonBefore ActionFunc\n\t// An action to execute before any subcommands are run, but after the context is ready\n\t// If a non-nil error is returned, no subcommands are run\n\tBefore ActionFunc\n\t// An action to execute after any subcommands are run, but after the subcommand has finished\n\tAfter ActionFunc\n\t// The action to execute when no subcommands are specified\n\tAction ActionFunc\n\t// DefaultCommand is the (optional)  command\n\t// to run if no command names are passed as CLI arguments.\n\tDefaultCommand *Command\n\t// OsExiter is the function used when the app exits. If not set defaults to os.Exit.\n\tOsExiter func(code int)\n}\n```\nApp is a wrapper for \\`urfave\\`'s \\`cli.App\\` struct. It should be created with the cli.NewApp() function. The main purpose of this wrapper is to parse commands and flags in the way we need, namely, if during parsing we find undefined commands or flags, instead of returning an error, we consider them as arguments, regardless of their position among the others registered commands and flags.\n\nFor example, CLI command: \\`terragrunt run-all apply --terragrunt-log-level debug --auto-approve --terragrunt-non-interactive\\` The \\`App\\` will runs the registered command \\`run-all\\`, define the registered flags \\`--terragrunt-log-level\\`, \\`--terragrunt-non-interactive\\`, and define args \\`apply --auto-approve\\` which can be obtained from the App context, ctx.Args().Slice()\n\n```go\nfunc NewApp() *App\n```\nNewApp returns app new App instance.\n\n```go\nfunc (app *App) AddCommands(cmds ...*Command)\n```\nAddCommands adds new commands.\n\n```go\nfunc (app *App) AddFlags(flags ...Flag)\n```\nAddFlags adds new flags.\n\n```go\nfunc (app *App) Run(arguments []string) error\n```\nRun is the entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination.\n\n```go\nfunc (app *App) VisibleCommands() []*cli.Command\n```\nVisibleCommands returns a slice of the Commands used for help.\n\n```go\nfunc (app *App) VisibleFlags() Flags\n```\nVisibleFlags returns a slice of the Flags used for help.\n\n```go\ntype Args []string\n```\nArgs provides convenient access to CLI arguments.\n\n```go\nfunc (args *Args) CommandName() string\n```\nCommandName returns the first value if it starts without a dash \\`-\\`, otherwise that means the args do not consist any command and an empty string is returned.\n\n```go\nfunc (args *Args) First() string\n```\nFirst returns the first argument, or else a blank string\n\n```go\nfunc (args *Args) Get(n int) string\n```\nGet returns the nth argument, or else a blank string\n\n```go\nfunc (args *Args) Len() int\n```\nLen returns the length of the wrapped slice\n\n```go\nfunc (args *Args) Normalize(acts ...NormalizeActsType) *Args\n```\nNormalize formats the arguments according to the given actions. if the given act is:\n\n\t`SingleDashFlag` - converts all arguments containing double dashes to single dashes\n\t`DoubleDashFlag` - converts all arguments containing signle dashes to double dashes\n\n```go\nfunc (args *Args) Present() bool\n```\nPresent checks if there are any arguments present\n\n```go\nfunc (args *Args) Slice() []string\n```\nSlice returns a copy of the internal slice\n\n```go\nfunc (args *Args) Tail() []string\n```\nTail returns the rest of the arguments (not the first one) or else an empty string slice\n\n```go\ntype BoolFlag struct {\n\n\t// The name of the flag.\n\tName string\n\t// The default value of the flag to display in the help, if it is empty, the value is taken from `Destination`.\n\tDefaultText string\n\t// A short usage description to display in help.\n\tUsage string\n\t// Aliases are usually used for the short flag name, like `-h`.\n\tAliases []string\n\t// The name of the env variable that is parsed and assigned to `Destination` before the flag value.\n\tEnvVar string\n\t// The action to execute when flag is specified\n\tAction ActionFunc\n\t// The pointer to which the value of the flag or env var is assigned.\n\t// It also uses as the default value displayed in the help.\n\tDestination *bool\n\t// If set to true, then the assigned flag value will be inverted\n\tNegative bool\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (flag *BoolFlag) Apply(set *libflag.FlagSet) error\n```\nApply applies Flag settings to the given flag set.\n\n```go\nfunc (flag *BoolFlag) GetCategory() string\n```\nGetCategory returns the category for the flag. Implements \\`cli.DocGenerationFlag.GetCategory\\` required to generate help.\n\n```go\nfunc (flag *BoolFlag) GetDefaultText() string\n```\nGetDefaultText returns the flags value as string representation and an empty string if the flag takes no value at all.\n\n```go\nfunc (flag *BoolFlag) GetEnvVars() []string\n```\nGetEnvVars returns the env vars for this flag.\n\n```go\nfunc (flag *BoolFlag) GetUsage() string\n```\nGetUsage returns the usage string for the flag.\n\n```go\nfunc (flag *BoolFlag) GetValue() string\n```\nGetValue returns the flags value as string representation and an empty string if the flag takes no value at all. Implements \\`cli.DocGenerationFlag.GetValue\\` required to generate help.\n\n```go\nfunc (flag *BoolFlag) IsSet() bool\n```\nIsSet returns true if the flag was set either evn, by env var or arg flag. Implements \\`cli.flag.IsSet\\` required to generate help.\n\n```go\nfunc (flag *BoolFlag) LookupEnv(envVar string) *string\n```\n\n```go\nfunc (flag *BoolFlag) Names() []string\n```\nNames returns the names of the flag.\n\n```go\nfunc (flag *BoolFlag) RunAction(ctx *Context) error\n```\nRunAction implements ActionableFlag.RunAction\n\n```go\nfunc (flag *BoolFlag) String() string\n```\nString returns a readable representation of this value (for usage defaults).\n\n```go\nfunc (flag *BoolFlag) TakesValue() bool\n```\nTakesValue returns true of the flag takes a value, otherwise false. Implements \\`cli.DocGenerationFlag.TakesValue\\` required to generate help.\n\n```go\nfunc (flag *BoolFlag) Value() FlagValue\n```\n\n```go\ntype Command struct {\n\t// The name of the cmd\n\tName string\n\t// A list of aliases for the cmd\n\tAliases []string\n\t// A short description of the usage of this cmd\n\tUsage string\n\t// Custom text to show on USAGE section of help\n\tUsageText string\n\t// A longer explanation of how the cmd works\n\tDescription string\n\t// List of flags to parse\n\tFlags Flags\n\t// Full name of cmd for help, defaults to full cmd name, including parent commands.\n\tHelpName string\n\t// if this is a root \"special\" cmd\n\tIsRoot bool\n\t// Boolean to hide this cmd from help\n\tHidden bool\n\t// CustomHelpTemplate the text template for the cmd help topic.\n\t// cli.go uses text/template to render templates. You can\n\t// render custom help text by setting this variable.\n\tCustomHelpTemplate string\n\t// List of child commands\n\tSubcommands Commands\n\t// Treat all flags as normal arguments if true\n\tSkipFlagParsing bool\n\t// Boolean to disable the parsing command, but it will still be shown in the help.\n\tSkipRunning bool\n\t// An action to execute before any subcommands are run, but after the context is ready\n\t// If a non-nil error is returned, no subcommands are run\n\tBefore ActionFunc\n\t// An action to execute after any subcommands are run, but after the subcommand has finished\n\tAfter ActionFunc\n\t// The action to execute when no subcommands are specified\n\tAction ActionFunc\n}\n```\n\n```go\nfunc (cmd *Command) HasName(name string) bool\n```\nHasName returns true if Command.Name matches given name\n\n```go\nfunc (cmd *Command) Names() []string\n```\nNames returns the names including short names and aliases.\n\n```go\nfunc (cmd *Command) Run(ctx *Context, args ...string) (err error)\n```\nRun parses the given args for the presence of flags as well as subcommands. If this is the final command, starts its execution.\n\n```go\nfunc (cmd *Command) Subcommand(name string) *Command\n```\nSubcommand returns a subcommand that matches the given name.\n\n```go\nfunc (cmd *Command) VisibleFlags() Flags\n```\nVisibleFlags returns a slice of the Flags, used by \\`urfave/cli\\` package to generate help.\n\n```go\nfunc (cmd Command) VisibleSubcommands() []*cli.Command\n```\nVisibleSubCommands returns a slice of the Commands with Hidden=false. Used by \\`urfave/cli\\` package to generate help.\n\n```go\ntype Commands []*Command\n```\n\n```go\nfunc (commands *Commands) Add(cmd *Command)\n```\nAdd adds a new cmd to the list.\n\n```go\nfunc (commands Commands) Filter(names []string) Commands\n```\nFilter returns a list of commands filtered by the given names.\n\n```go\nfunc (commands Commands) Get(name string) *Command\n```\nGet returns a Command by the given name.\n\n```go\nfunc (commands Commands) Len() int\n```\n\n```go\nfunc (commands Commands) Less(i, j int) bool\n```\n\n```go\nfunc (commands Commands) SkipRunning() Commands\n```\nSkipRunning prevents running commands as the final commands, but keep showing them in help.\n\n```go\nfunc (commands Commands) Swap(i, j int)\n```\n\n```go\nfunc (commands Commands) VisibleCommands() []*cli.Command\n```\nVisibleCommands returns a slice of the Commands with Hidden=false. Used by \\`urfave/cli\\` package to generate help.\n\n```go\ntype Context struct {\n\tcontext.Context\n\t*App\n\tCommand *Command\n\t// contains filtered or unexported fields\n}\n```\nContext can be used to retrieve context-specific args and parsed command-line options.\n\n```go\nfunc (ctx *Context) Args() *Args\n```\nArgs returns the command line arguments associated with the context.\n\n```go\nfunc (ctx *Context) Clone(command *Command, args Args) *Context\n```\n\n```go\nfunc (ctx *Context) Value(key any) any\n```\n\n```go\nfunc (ctx Context) WithValue(key, val any) *Context\n```\n\n```go\ntype Flag interface {\n\tValue() FlagValue\n\n\t// `urfave/cli/v2` uses to generate help\n\tcli.DocGenerationFlag\n}\n```\n\n```go\ntype FlagType[T any] interface {\n\tlibflag.Getter\n\tClone(dest *T) FlagType[T]\n}\n```\n\n```go\ntype FlagValue interface {\n\tlibflag.Getter\n\n\tGetDefaultText() string\n\n\tIsSet() bool\n\n\t// optional interface to indicate boolean flags that can be\n\t// supplied without \"=value\" text\n\tIsBoolFlag() bool\n}\n```\n\n```go\ntype Flags []Flag\n```\n\n```go\nfunc (flags *Flags) Add(newFlags ...Flag)\n```\nAdd adds a new flag to the list.\n\n```go\nfunc (flags Flags) Filter(names []string) Flags\n```\nFilter returns a list of flags filtered by the given names.\n\n```go\nfunc (flags Flags) Get(name string) Flag\n```\nGet returns a Flag by the given name.\n\n```go\nfunc (flags Flags) Len() int\n```\n\n```go\nfunc (flags Flags) Less(i, j int) bool\n```\n\n```go\nfunc (flags Flags) RunActions(ctx *Context) error\n```\n\n```go\nfunc (flags Flags) Sort() Flags\n```\n\n```go\nfunc (flags Flags) Swap(i, j int)\n```\n\n```go\nfunc (flags Flags) VisibleFlags() Flags\n```\nVisibleFlags returns a slice of the Flags. Used by \\`urfave/cli\\` package to generate help.\n\n```go\ntype GenericFlag[T GenericType] struct {\n\n\t// The name of the flag.\n\tName string\n\t// The default value of the flag to display in the help, if it is empty, the value is taken from `Destination`.\n\tDefaultText string\n\t// A short usage description to display in help.\n\tUsage string\n\t// Aliases are usually used for the short flag name, like `-h`.\n\tAliases []string\n\t// The name of the env variable that is parsed and assigned to `Destination` before the flag value.\n\tEnvVar string\n\t// The action to execute when flag is specified\n\tAction ActionFunc\n\t// The pointer to which the value of the flag or env var is assigned.\n\t// It also uses as the default value displayed in the help.\n\tDestination *T\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (flag *GenericFlag[T]) Apply(set *libflag.FlagSet) error\n```\nApply applies Flag settings to the given flag set.\n\n```go\nfunc (flag *GenericFlag) GetCategory() string\n```\nGetCategory returns the category for the flag. Implements \\`cli.DocGenerationFlag.GetCategory\\` required to generate help.\n\n```go\nfunc (flag *GenericFlag[T]) GetDefaultText() string\n```\nGetDefaultText returns the flags value as string representation and an empty string if the flag takes no value at all.\n\n```go\nfunc (flag *GenericFlag[T]) GetEnvVars() []string\n```\nGetEnvVars returns the env vars for this flag.\n\n```go\nfunc (flag *GenericFlag[T]) GetUsage() string\n```\nGetUsage returns the usage string for the flag.\n\n```go\nfunc (flag *GenericFlag) GetValue() string\n```\nGetValue returns the flags value as string representation and an empty string if the flag takes no value at all. Implements \\`cli.DocGenerationFlag.GetValue\\` required to generate help.\n\n```go\nfunc (flag *GenericFlag) IsSet() bool\n```\nIsSet returns true if the flag was set either evn, by env var or arg flag. Implements \\`cli.flag.IsSet\\` required to generate help.\n\n```go\nfunc (flag *GenericFlag) LookupEnv(envVar string) *string\n```\n\n```go\nfunc (flag *GenericFlag[T]) Names() []string\n```\nNames returns the names of the flag.\n\n```go\nfunc (flag *GenericFlag[T]) RunAction(ctx *Context) error\n```\nRunAction implements ActionableFlag.RunAction\n\n```go\nfunc (flag *GenericFlag[T]) String() string\n```\nString returns a readable representation of this value (for usage defaults).\n\n```go\nfunc (flag *GenericFlag) TakesValue() bool\n```\nTakesValue returns true of the flag takes a value, otherwise false. Implements \\`cli.DocGenerationFlag.TakesValue\\` required to generate help.\n\n```go\nfunc (flag *GenericFlag) Value() FlagValue\n```\n\n```go\ntype GenericType interface {\n\tstring | int | int64\n}\n```\n\n```go\ntype InvalidCommandNameError string\n```\n\n```go\nfunc (cmdName InvalidCommandNameError) Error() string\n```\n\n```go\ntype InvalidKeyValueError struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewInvalidKeyValueError(sep, value string) *InvalidKeyValueError\n```\n\n```go\nfunc (err InvalidKeyValueError) Error() string\n```\n\n```go\ntype LookupEnvFuncType func(key string) (string, bool)\n```\n\n```go\ntype MapFlag[K MapFlagKeyType, V MapFlagValueType] struct {\n\tName        string\n\tDefaultText string\n\tUsage       string\n\tAliases     []string\n\tAction      ActionFunc\n\tEnvVar      string\n\n\tDestination *map[K]V\n\tSplitter    SplitterFunc\n\tEnvVarSep   string\n\tKeyValSep   string\n\t// contains filtered or unexported fields\n}\n```\nMapFlag is a key value flag.\n\n```go\nfunc (flag *MapFlag[K, V]) Apply(set *libflag.FlagSet) error\n```\nApply applies Flag settings to the given flag set.\n\n```go\nfunc (flag *MapFlag) GetCategory() string\n```\nGetCategory returns the category for the flag. Implements \\`cli.DocGenerationFlag.GetCategory\\` required to generate help.\n\n```go\nfunc (flag *MapFlag[K, V]) GetDefaultText() string\n```\nGetDefaultText returns the flags value as string representation and an empty string if the flag takes no value at all.\n\n```go\nfunc (flag *MapFlag[K, V]) GetEnvVars() []string\n```\nGetEnvVars returns the env vars for this flag.\n\n```go\nfunc (flag *MapFlag[K, V]) GetUsage() string\n```\nGetUsage returns the usage string for the flag.\n\n```go\nfunc (flag *MapFlag) GetValue() string\n```\nGetValue returns the flags value as string representation and an empty string if the flag takes no value at all. Implements \\`cli.DocGenerationFlag.GetValue\\` required to generate help.\n\n```go\nfunc (flag *MapFlag) IsSet() bool\n```\nIsSet returns true if the flag was set either evn, by env var or arg flag. Implements \\`cli.flag.IsSet\\` required to generate help.\n\n```go\nfunc (flag *MapFlag) LookupEnv(envVar string) *string\n```\n\n```go\nfunc (flag *MapFlag[K, V]) Names() []string\n```\nNames returns the names of the flag.\n\n```go\nfunc (flag *MapFlag[K, V]) RunAction(ctx *Context) error\n```\nRunAction implements ActionableFlag.RunAction\n\n```go\nfunc (flag *MapFlag[K, V]) String() string\n```\nString returns a readable representation of this value (for usage defaults).\n\n```go\nfunc (flag *MapFlag) TakesValue() bool\n```\nTakesValue returns true of the flag takes a value, otherwise false. Implements \\`cli.DocGenerationFlag.TakesValue\\` required to generate help.\n\n```go\nfunc (flag *MapFlag) Value() FlagValue\n```\n\n```go\ntype MapFlagKeyType interface {\n\tGenericType\n}\n```\n\n```go\ntype MapFlagValueType interface {\n\tGenericType | bool\n}\n```\n\n```go\ntype NormalizeActsType byte\n```\n\n```go\nconst (\n\tSingleDashFlag NormalizeActsType = iota\n\tDoubleDashFlag NormalizeActsType = iota\n)\n```\n\n```go\ntype SliceFlag[T SliceFlagType] struct {\n\n\t// The name of the flag.\n\tName string\n\t// The default value of the flag to display in the help, if it is empty, the value is taken from `Destination`.\n\tDefaultText string\n\t// A short usage description to display in help.\n\tUsage string\n\t// Aliases are usually used for the short flag name, like `-h`.\n\tAliases []string\n\t// The name of the env variable that is parsed and assigned to `Destination` before the flag value.\n\tEnvVar string\n\t// The action to execute when flag is specified\n\tAction ActionFunc\n\t// The pointer to which the value of the flag or env var is assigned.\n\t// It also uses as the default value displayed in the help.\n\tDestination *[]T\n\t// The func used to split the EvnVar, by default `strings.Split`\n\tSplitter SplitterFunc\n\t// The Env Var separator that is passed to the Splitter function as an argument\n\tEnvVarSep string\n\t// contains filtered or unexported fields\n}\n```\nSliceFlag is a multiple flag.\n\n```go\nfunc (flag *SliceFlag[T]) Apply(set *libflag.FlagSet) error\n```\nApply applies Flag settings to the given flag set.\n\n```go\nfunc (flag *SliceFlag) GetCategory() string\n```\nGetCategory returns the category for the flag. Implements \\`cli.DocGenerationFlag.GetCategory\\` required to generate help.\n\n```go\nfunc (flag *SliceFlag[T]) GetDefaultText() string\n```\nGetDefaultText returns the flags value as string representation and an empty string if the flag takes no value at all.\n\n```go\nfunc (flag *SliceFlag[T]) GetEnvVars() []string\n```\nGetEnvVars returns the env vars for this flag.\n\n```go\nfunc (flag *SliceFlag[T]) GetUsage() string\n```\nGetUsage returns the usage string for the flag.\n\n```go\nfunc (flag *SliceFlag) GetValue() string\n```\nGetValue returns the flags value as string representation and an empty string if the flag takes no value at all. Implements \\`cli.DocGenerationFlag.GetValue\\` required to generate help.\n\n```go\nfunc (flag *SliceFlag) IsSet() bool\n```\nIsSet returns true if the flag was set either evn, by env var or arg flag. Implements \\`cli.flag.IsSet\\` required to generate help.\n\n```go\nfunc (flag *SliceFlag) LookupEnv(envVar string) *string\n```\n\n```go\nfunc (flag *SliceFlag[T]) Names() []string\n```\nNames returns the names of the flag.\n\n```go\nfunc (flag *SliceFlag[T]) RunAction(ctx *Context) error\n```\nRunAction implements ActionableFlag.RunAction\n\n```go\nfunc (flag *SliceFlag[T]) String() string\n```\nString returns a readable representation of this value (for usage defaults).\n\n```go\nfunc (flag *SliceFlag) TakesValue() bool\n```\nTakesValue returns true of the flag takes a value, otherwise false. Implements \\`cli.DocGenerationFlag.TakesValue\\` required to generate help.\n\n```go\nfunc (flag *SliceFlag) Value() FlagValue\n```\n\n```go\ntype SliceFlagType interface {\n\tGenericType\n}\n```\n\n```go\ntype SplitterFunc func(s, sep string) []string\n```\nSplitterFunc is used to parse flags containing multiple values.\n\n","path":"github.com/c3xdev/c3x/internal/hclstack/pkg/cli","name":"cli","synopsis":"","isRedistributable":true}
