cmd

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SupportedVersionAll indicates that the command is available for all versions of Spacelift.
	SupportedVersionAll = "all"

	// SupportedVersionLatest indicates that the command is supported for SaaS, and will be supported
	// by Self-Hosted after the next Self-Hosted release.
	SupportedVersionLatest = "latest"
)
View Source
const EmptyArgsUsage = " "

EmptyArgsUsage is used to specify that the command arguments section shouldn't be displayed in the help text. This is a workaround to avoid having to change the entire template.

Variables

View Source
var AvailableOutputFormatStrings = []string{string(OutputFormatTable), string(OutputFormatJSON)}

AvailableOutputFormatStrings returns all the output formats available to users.

View Source
var FlagLimit = &cli.UintFlag{
	Name:  "limit",
	Usage: "[Optional] Limit the number of items to return",
}

FlagLimit is a flag used for limiting the number of items to return.

View Source
var FlagNoColor = &cli.BoolFlag{
	Name:  "no-color",
	Usage: "Disables coloring for the console output. Automatically enabled when the output is not a terminal.",
}

FlagNoColor disables coloring in the console output.

View Source
var FlagOutputFormat = &cli.StringFlag{
	Name:    "output",
	Aliases: []string{"o"},
	Usage:   fmt.Sprintf("Output `format`. Allowed values: %s", strings.Join(AvailableOutputFormatStrings, ", ")),
	Value:   string(OutputFormatTable),
}

FlagOutputFormat allows users to change the output format of commands that support it.

View Source
var FlagSearch = &cli.StringFlag{
	Name:  "search",
	Usage: "[Optional] Performs a full-text search.",
}

FlagSearch is a flag used for performing a full-text search.

View Source
var FlagShowLabels = &cli.BoolFlag{
	Name:  "show-labels",
	Usage: "[Optional] Indicates that labels should be printed when outputting data in the table format",
}

FlagShowLabels is a flag used for indicating that labels should be printed when outputting data in the table format.

Functions

func HandleNoColor added in v0.9.0

func HandleNoColor(ctx context.Context, cmd *cli.Command) (context.Context, error)

HandleNoColor handles FlagNoColor to disable console coloring.

func HumanizeAuditTrailResourceType added in v1.9.0

func HumanizeAuditTrailResourceType(resourceType string) string

func HumanizeBlueprintState added in v1.6.0

func HumanizeBlueprintState(state string) string

func HumanizeGitHash added in v0.12.0

func HumanizeGitHash(hash string) string

HumanizeGitHash shortens a Git hash to make it more readable.

func HumanizePolicyType added in v0.7.1

func HumanizePolicyType(policyType string) string

HumanizePolicyType converts the GraphQL PolicyType enum to a human readable string.

func HumanizeUnixSeconds added in v1.6.0

func HumanizeUnixSeconds(seconds int) string

func HumanizeVCSProvider added in v0.7.1

func HumanizeVCSProvider(provider string) string

HumanizeVCSProvider converts the GraphQL VCSProvider enum to a human readable string.

func OutputJSON

func OutputJSON(v interface{}) error

OutputJSON outputs the specified object as JSON.

func OutputTable

func OutputTable(data [][]string, hasHeader bool) error

OutputTable outputs the specified data as a table.

func PerformAllBefore added in v0.9.0

func PerformAllBefore(actions ...cli.BeforeFunc) cli.BeforeFunc

PerformAllBefore wraps all the specified BeforeFuncs into a single BeforeFunc.

func ResolveCommands added in v1.12.0

func ResolveCommands(instanceVersion SpaceliftInstanceVersion, allCommands []Command) []*cli.Command

ResolveCommands finds the set of command versions from allCommands and their subcommands that are available based on the specified Spacelift instance version.

Types

type Command added in v1.12.0

type Command struct {
	Name     string
	Usage    string
	Category string

	// Versions defines the available versions for the command.
	Versions []VersionedCommand

	// Subcommands gets the list of subcommands that support the specified version.
	Subcommands []Command
}

func (Command) FindLatestSupportedVersion added in v1.12.0

func (c Command) FindLatestSupportedVersion(instanceVersion SpaceliftInstanceVersion) *VersionedCommand

FindLatestSupportedVersion finds the latest supported version of the specified command. It returns nil if no version of the command is supported by the Spacelift instance.

type OutputFormat

type OutputFormat string

OutputFormat defines the way that the results of a command are output to the user.

const (
	// OutputFormatTable represents the output formatted in a table.
	OutputFormatTable OutputFormat = "table"

	// OutputFormatJSON represents the output formatted as JSON.
	OutputFormatJSON OutputFormat = "json"
)

func GetOutputFormat

func GetOutputFormat(cliCmd *cli.Command) (OutputFormat, error)

GetOutputFormat gets the selected output format based on the CLI args.

type SpaceliftInstanceType added in v1.12.0

type SpaceliftInstanceType uint
const (
	// SpaceliftInstanceTypeUnknown indicates that we don't know what type of instance spacectl
	// is being used against. This can happen before a profile has been created or if the credentials
	// have expired.
	SpaceliftInstanceTypeUnknown SpaceliftInstanceType = iota

	// SpaceliftInstanceTypeSaaS indicates we're talking to Spacelift SaaS.
	SpaceliftInstanceTypeSaaS

	// SpaceliftInstanceTypeSelfHosted indicates we're talking to a Self-Hosted instance.
	SpaceliftInstanceTypeSelfHosted
)

type SpaceliftInstanceVersion added in v1.12.0

type SpaceliftInstanceVersion struct {
	// InstanceType defines the type of instance we're connecting to.
	InstanceType SpaceliftInstanceType

	// Version indicates the Self-Hosted version we are communicating with. It will be nil for SaaS.
	Version *semver.Version
}

func (SpaceliftInstanceVersion) SimplifiedVersion added in v1.12.0

func (v SpaceliftInstanceVersion) SimplifiedVersion() *semver.Version

SimplifiedVersion returns the version (if set) without the prerelease or metadata parts.

func (SpaceliftInstanceVersion) String added in v1.12.0

func (v SpaceliftInstanceVersion) String() string

String returns a string representation of the instance version.

type SupportedVersion added in v1.12.0

type SupportedVersion string

SupportedVersion is used to indicate what versions of Spacelift certain spacectl commands are compatible with.

type VersionedCommand added in v1.12.0

type VersionedCommand struct {
	// EarliestVersion indicates that the command needs at least the indicated Self-Hosted version
	// in order to work.
	//
	// - SupportedVersionAll - indicates that the command can be used for any Spacelift version (both SaaS and Self-Hosted).
	// - SupportedVersionLatest - indicates that the command can be used with SaaS, but will not be available to Self-Hosted until the next release.
	// - 1.2.3, 2.5.0, etc - indicates that the command can be used with SaaS, or a Self-Hosted version equal to or higher than the specified version.
	EarliestVersion SupportedVersion

	// The CLI command definition.
	Command *cli.Command
}

Jump to

Keyboard shortcuts

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