commands

package
v0.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package commands define all Terramate commands. All commands must: - Be defined in its own package (eg.: ./commands/generate) - Define a `<cmd>.Spec` type declaring all variables that control the command behavior. - Implement the commands.Executor interface. - Never abort, panic or exit the process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasRequirement added in v0.15.0

func HasRequirement[T any](ctx context.Context, cli CLI, cmd Command) (*T, bool)

HasRequirement checks if the given command has requirement of type T, and returns it if found. If the command returns a single requirement, it will be checked against T. If it returns a RequirementsList, each element will be checked.

Types

type CLI added in v0.15.0

type CLI interface {
	Version() string
	Product() string
	PrettyProduct() string

	WorkingDir() string

	Printers() printer.Printers
	Stdout() io.Writer
	Stderr() io.Writer
	Stdin() io.Reader

	// Config returns the userconfig.
	Config() cliconfig.Config

	// Engine returns the engine.
	// Will only be available for commands that have EngineRequirement.
	Engine() *engine.Engine

	// Reload reloads the engine config and re-runs post-init hooks.
	// Must only be called by commands that have the engine requirement.
	Reload(ctx context.Context) error
}

CLI is the interface for common CLI data required by commands.

type Command added in v0.15.0

type Command interface {
	// Name of the comamnd.
	Name() string

	// Requirements is a generic interface to query a command for common requirements
	// that will be fulfilled by the CLI before executing it.
	//
	// The result can either by a single requirement, or a RequirementsList.
	Requirements(context.Context, CLI) any

	// Exec executes the command.
	Exec(context.Context, CLI) error
}

Command is an interface for a command handler.

type EngineRequirement added in v0.15.0

type EngineRequirement struct {
	LoadTerragruntModules bool
	Experiments           []string
}

EngineRequirement is a requirement for commands that need the configuration to be loaded. Commands that don't have this requirement set may not call CLI.Engine().

func RequireEngine added in v0.15.0

func RequireEngine(opts ...RequireEngineOpt) *EngineRequirement

RequireEngine creates a new EngineRequirement with the given options.

type RequireEngineOpt added in v0.15.0

type RequireEngineOpt func(*EngineRequirement)

RequireEngineOpt is the option type for RequireEngine().

func WithExperiments added in v0.15.0

func WithExperiments(names ...string) RequireEngineOpt

WithExperiments an option for RequireEngine() to require given experiments to be enabled. This is part of the engine requirement, because experiments are specified in the config.

func WithTerragrunt added in v0.15.0

func WithTerragrunt(loadModules bool) RequireEngineOpt

WithTerragrunt an option for RequireEngine() to control loading of Terragrunt modules for change detection and dependency tracking.

type RequirementsList added in v0.15.0

type RequirementsList []any

RequirementsList allows to return multiple requirements from Command.Requirements().

Directories

Path Synopsis
Package clone provides the clone command.
Package clone provides the clone command.
cloud
drift/show
Package show provides the cloud drift show command.
Package show provides the cloud drift show command.
info
Package info provides the cloud info command.
Package info provides the cloud info command.
login
Package login provides login commands.
Package login provides login commands.
Package completions provides the install-completions command.
Package completions provides the install-completions command.
component
create
Package create provides the component create command.
Package create provides the component create command.
debug
show/generate_origins
Package generateorigins provides the generate-origins command.
Package generateorigins provides the generate-origins command.
show/globals
Package globals provides the debug globals command.
Package globals provides the debug globals command.
show/metadata
Package metadata provides the show-metadata command.
Package metadata provides the show-metadata command.
show/runtime_env
Package runtimeenv provides the show-runtime-env command.
Package runtimeenv provides the show-runtime-env command.
experimental
eval
Package eval provides the "experimental eval" and "experimental partial-eval" commands.
Package eval provides the "experimental eval" and "experimental partial-eval" commands.
rungraph
Package rungraph provides the run-graph command.
Package rungraph provides the run-graph command.
vendordownload
Package vendordownload provides the vendor download command.
Package vendordownload provides the vendor download command.
Package fmt provides the fmt command.
Package fmt provides the fmt command.
Package generate provides the generate command.
Package generate provides the generate command.
package
create
Package create provides the package create command.
Package create provides the package create command.
Package requiredversion provides the required-version command.
Package requiredversion provides the required-version command.
Package run provides the run command.
Package run provides the run command.
Package scaffold provides the scaffold command.
Package scaffold provides the scaffold command.
Package script provides the script command.
Package script provides the script command.
info
Package info provides the "script info" command.
Package info provides the "script info" command.
list
Package list provides the script list command.
Package list provides the script list command.
run
Package run provides the script run command.
Package run provides the script run command.
tree
Package tree provides the script tree command.
Package tree provides the script tree command.
stack
create
Package create provides the create stack command.
Package create provides the create stack command.
list
Package list provides the list command.
Package list provides the list command.
Package trigger provides the trigger command.
Package trigger provides the trigger command.
Package ui implements the terramate ui command.
Package ui implements the terramate ui command.
Package version provides the version command.
Package version provides the version command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址