Documentation
¶
Overview ¶
Package tui provides the Terminal User Interface (TUI) of the CLI.
Index ¶
- Constants
- func ConfigureLogging(logLevel, logFmt, logdest string, stdout, stderr io.Writer) error
- func DefaultAfterConfigHandler(ctx context.Context, c *CLI) (commands.Executor, bool, bool, error)
- func DefaultBeforeConfigHandler(ctx context.Context, c *CLI) (cmd commands.Executor, found bool, cont bool, err error)
- type CLI
- func (c *CLI) Config() *config.Root
- func (c *CLI) DidKongExit() bool
- func (c *CLI) Engine() *engine.Engine
- func (c *CLI) Exec(args []string)
- func (c *CLI) InitAnalytics(cmd string, opts ...tel.MessageOpt)
- func (c *CLI) InputSpec() any
- func (c *CLI) Printers() printer.Printers
- func (c *CLI) Version() string
- func (c *CLI) WorkingDir() string
- type FlagSpec
- type Handler
- type Option
- func WithCompactHelp(b bool) Option
- func WithDescription(desc string) Option
- func WithExpandSubcommandsInHelp() Option
- func WithHCLOptions(hclOpts ...hcl.Option) Option
- func WithHelpPrinter(p kong.HelpPrinter) Option
- func WithName(name string) Option
- func WithSpecHandler(a any, beforeHandler, afterHandler Handler, checkers ...RootFlagHandlers) Option
- func WithStderr(w io.Writer) Option
- func WithStdin(r io.Reader) Option
- func WithStdout(w io.Writer) Option
- func WithVersion(v string) Option
- type RootFlagHandlers
Constants ¶
const ErrSetup errors.Kind = "failed to setup Terramate"
ErrSetup is the error returned when the CLI fails to setup its initial values.
const KongContext contextStr = "kong.context"
KongContext is the context key for the Kong context.
const KongError contextStr = "kong.error"
KongError is the context key for the Kong error.
Variables ¶
This section is empty.
Functions ¶
func ConfigureLogging ¶
ConfigureLogging configures Terramate global logging.
func DefaultAfterConfigHandler ¶
DefaultAfterConfigHandler implements the default flags handling for when the config is already parsed. Use WithSpecHandler if you need a different behavior.
func DefaultBeforeConfigHandler ¶
func DefaultBeforeConfigHandler(ctx context.Context, c *CLI) (cmd commands.Executor, found bool, cont bool, err error)
DefaultBeforeConfigHandler implements the default flags handling for when the config is not yet parsed. Use WithSpecHandler if you need a different behavior.
Types ¶
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI is the Terramate command-line interface opaque type. The default flag spec is [input.Spec] and handler is DefaultAfterConfigHandler.
func (*CLI) DidKongExit ¶
DidKongExit returns true if Kong intends to exit.
func (*CLI) InitAnalytics ¶
func (c *CLI) InitAnalytics(cmd string, opts ...tel.MessageOpt)
InitAnalytics initializes the analytics record.
func (*CLI) WorkingDir ¶
WorkingDir returns the CLI working directory.
type FlagSpec ¶
type FlagSpec struct { DisableCheckpoint bool `hidden:"true" optional:"true" default:"false" help:"Disable checkpoint checks for updates."` DisableCheckpointSignature bool `hidden:"true" optional:"true" default:"false" help:"Disable checkpoint signature."` CPUProfiling bool `hidden:"true" optional:"true" default:"false" help:"Create a CPU profile file when running"` Create struct { Path string `arg:"" optional:"" name:"path" predictor:"file" help:"Path of the new stack."` ID string `help:"Set the ID of the stack, defaults to an UUIDv4 string."` Name string `help:"Set the name of the stack, defaults to the basename of <path>"` Description string `help:"Set the description of the stack, defaults to <name>"` Import []string `help:"Add 'import' block to the configuration of the new stack."` After []string `help:"Add 'after' attribute to the configuration of the new stack."` Before []string `help:"Add 'before' attribute to the configuration of the new stack."` Wants []string `help:"Add 'wants' attribute to the configuration of the new stack."` WantedBy []string `help:"Add 'wanted_by' attribute to the configuration of the new stack."` Watch []string `help:"Add 'watch' attribute to the configuration of the new stack."` IgnoreExisting bool `help:"Skip creation without error when the stack already exist."` AllTerraform bool `help:"Import existing Terraform Root Modules as stacks."` AllTerragrunt bool `help:"Import existing Terragrunt Modules as stacks."` EnsureStackIDs bool `name:"ensure-stack-ids" help:"Set the ID of existing stacks that do not set an ID to a new UUIDv4."` NoGenerate bool `help:"Do not run code generation after creating the new stack."` } `cmd:"" help:"Create or import stacks."` Fmt struct { Files []string `arg:"" optional:"true" predictor:"file" help:"List of files to be formatted."` Check bool `hidden:"" help:"Lists unformatted files but do not change them. (Exits with 0 if all is formatted, 1 otherwise)"` DetailedExitCode bool `help:"Return a detailed exit code: 0 nothing changed, 1 an error happened, 2 changes were made."` } `cmd:"" help:"Format configuration files."` List struct { Why bool `help:"Shows the reason why the stack has changed."` Target string `help:"Select the deployment target of the filtered stacks."` RunOrder bool `default:"false" help:"Sort listed stacks by order of execution"` // contains filtered or unexported fields } `cmd:"" help:"List stacks."` Run struct { // contains filtered or unexported fields } `cmd:"" help:"Run command in the stacks"` Generate struct { Parallel int `env:"TM_ARG_GENERATE_PARALLEL" short:"j" optional:"true" help:"Set the parallelism of code generation"` DetailedExitCode bool `default:"false" help:"Return a detailed exit code: 0 nothing changed, 1 an error happened, 2 changes were made."` } `cmd:"" help:"Run Code Generation in stacks."` Script struct { List struct{} `cmd:"" help:"List scripts."` Tree struct{} `cmd:"" help:"Dump a tree of scripts."` Info struct { Cmds []string `arg:"" optional:"true" passthrough:"" help:"Script to show info for."` } `cmd:"" help:"Show detailed information about a script"` Run struct { // contains filtered or unexported fields } `cmd:"" help:"Run a Terramate Script in stacks."` } `cmd:"" help:"Use Terramate Scripts"` Debug struct { Show struct { Metadata struct{} `cmd:"" help:"Show metadata available in stacks."` Globals struct{} `cmd:"" help:"Show globals available in stacks."` GenerateOrigins struct { } `cmd:"" help:"Show details about generated code in stacks."` RuntimeEnv struct{} `cmd:"" help:"Show available run-time environment variables (ENV) in stacks."` } `cmd:"" help:"Show configuration details of stacks."` } `cmd:"" help:"Debug Terramate configuration."` Cloud struct { Login struct { Google bool `optional:"true" help:"authenticate with google credentials"` Github bool `optional:"true" help:"authenticate with github credentials"` SSO bool `optional:"true" help:"authenticate with SSO credentials"` } `cmd:"" help:"Sign in to Terramate Cloud."` Info struct{} `cmd:"" help:"Show your current Terramate Cloud login status."` Drift struct { Show struct { Target string `help:"Show stacks from the given deployment target."` } `cmd:"" help:"Show the current drift of a stack."` } `cmd:"" help:"Interact with Terramate Cloud Drift Detection."` } `cmd:"" help:"Interact with Terramate Cloud"` Trigger struct { Stack string `arg:"" optional:"true" name:"stack" predictor:"file" help:"The stacks path."` Recursive bool `default:"false" help:"Recursively triggers all child stacks of the given path"` Change bool `default:"false" help:"Trigger stacks as changed"` IgnoreChange bool `default:"false" help:"Trigger stacks to be ignored by change detection"` Reason string `default:"" name:"reason" help:"Set a reason for triggering the stack."` // contains filtered or unexported fields } `cmd:"" hidden:"" help:"Mark a stack as changed so it will be triggered in Change Detection. (DEPRECATED)"` Experimental struct { Clone struct { SrcDir string `arg:"" name:"srcdir" predictor:"file" help:"Path of the stack being cloned."` DestDir string `arg:"" name:"destdir" predictor:"file" help:"Path of the new stack."` SkipChildStacks bool `default:"false" help:"Do not clone nested child stacks."` NoGenerate bool `help:"Do not run code generation after cloning the stacks."` } `cmd:"" help:"Clone a stack."` Trigger struct { Stack string `arg:"" optional:"true" name:"stack" predictor:"file" help:"The stacks path."` Recursive bool `default:"false" help:"Recursively triggers all child stacks of the given path"` Change bool `default:"false" help:"Trigger stacks as changed"` IgnoreChange bool `default:"false" help:"Trigger stacks to be ignored by change detection"` Reason string `default:"" name:"reason" help:"Set a reason for triggering the stack."` // contains filtered or unexported fields } `cmd:"" hidden:"" help:"Mark a stack as changed so it will be triggered in Change Detection. (DEPRECATED)"` RunGraph struct { Outfile string `short:"o" predictor:"file" default:"" help:"Output .dot file"` Label string `short:"l" default:"stack.name" help:"Label used in graph nodes (it could be either \"stack.name\" or \"stack.dir\""` } `cmd:"" help:"Generate a graph of the execution order"` Vendor struct { Download struct { Dir string `short:"d" predictor:"file" default:"" help:"dir to vendor downloaded project"` Source string `arg:"" name:"source" help:"Terraform module source URL, must be Git/Github and should not contain a reference"` Reference string `arg:"" name:"ref" help:"Reference of the Terraform module to vendor"` } `cmd:"" help:"Downloads a Terraform module and stores it on the project vendor dir"` } `cmd:"" help:"Manages vendored Terraform modules"` Eval struct { Global map[string]string `short:"g" help:"set/override globals. eg.: --global name=<expr>"` AsJSON bool `help:"Outputs the result as a JSON value"` Exprs []string `arg:"" help:"expressions to be evaluated" name:"expr" passthrough:""` } `cmd:"" help:"Eval expression"` PartialEval struct { Global map[string]string `short:"g" help:"set/override globals. eg.: --global name=<expr>"` Exprs []string `arg:"" help:"expressions to be partially evaluated" name:"expr" passthrough:""` } `cmd:"" help:"Partial evaluate the expressions"` GetConfigValue struct { Global map[string]string `short:"g" help:"set/override globals. eg.: --global name=<expr>"` AsJSON bool `help:"Outputs the result as a JSON value"` Vars []string `arg:"" help:"variable to be retrieved" name:"var" passthrough:""` } `cmd:"" help:"Get configuration value"` Cloud struct { Login struct{} `cmd:"" help:"login for cloud.terramate.io (DEPRECATED)"` Info struct{} `cmd:"" help:"cloud information status (DEPRECATED)"` Drift struct { Show struct { } `cmd:"" help:"show drifts (DEPRECATED)"` } `cmd:"" help:"manage cloud drifts (DEPRECATED)"` } `cmd:"" hidden:"" help:"Terramate Cloud commands (DEPRECATED)"` } `cmd:"" help:"Use experimental features."` InstallCompletions kongplete.InstallCompletions `cmd:"" help:"Install shell completions."` Version struct{} `cmd:"" help:"Show Terramate version"` // contains filtered or unexported fields }
FlagSpec defines the default Terramate flags and commands.
type Option ¶
Option is a function that modifies the CLI behavior.
func WithCompactHelp ¶
WithCompactHelp is an option to modify the helper compact option.
func WithDescription ¶
WithDescription is an option to modify the project description.
func WithExpandSubcommandsInHelp ¶
func WithExpandSubcommandsInHelp() Option
WithExpandSubcommandsInHelp is an option to expand the subcommands in the help. By default they are not shown.
func WithHCLOptions ¶
WithHCLOptions is an option to set the HCL options for the CLI.
func WithHelpPrinter ¶
func WithHelpPrinter(p kong.HelpPrinter) Option
WithHelpPrinter allows for customizing the help output.
func WithSpecHandler ¶
func WithSpecHandler(a any, beforeHandler, afterHandler Handler, checkers ...RootFlagHandlers) Option
WithSpecHandler is an option to set the flag spec and handler for the CLI.
func WithStderr ¶
WithStderr is an option to modify the CLI stderr channel.
func WithStdout ¶
WithStdout is an option to modify the CLI stdout channel.
func WithVersion ¶
WithVersion is an option to modify the CLI version. Default is `terramate.Version()`.
type RootFlagHandlers ¶
type RootFlagHandlers func(parsed any, cli *CLI) (name string, val any, run func(c *CLI, value any) error, isset bool)
RootFlagHandlers is a function signature for root flag handlers.
func DefaultRootFlagHandlers ¶
func DefaultRootFlagHandlers() []RootFlagHandlers
DefaultRootFlagHandlers returns the CLI default flag handlers for global flags that can be used alone (without a command). For example: terramate --version
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package cliauth provides the helper functions for loading the Terramate Cloud credentials.
|
Package cliauth provides the helper functions for loading the Terramate Cloud credentials. |
Package cliconfig implements the parser and load of Terramate CLI Configuration files (.terramaterc and terramate.rc).
|
Package cliconfig implements the parser and load of Terramate CLI Configuration files (.terramaterc and terramate.rc). |
Package clitest provides constants and errors kind reused by the cli implementation and the e2e test infrastructure.
|
Package clitest provides constants and errors kind reused by the cli implementation and the e2e test infrastructure. |
Package out provides output functionality, including verboseness level and normal/error messages support.
|
Package out provides output functionality, including verboseness level and normal/error messages support. |
Package telemetry provides types and helpers for CLI telemetry.
|
Package telemetry provides types and helpers for CLI telemetry. |