customcommand

package
v1.233.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package customcommand holds the argument and flag semantics of custom commands declared in atmos.yaml: how positional arguments are resolved against their defaults, how they travel from the pre-run hook to the executor, and which flag types are supported.

Index

Constants

View Source
const (
	// FlagTypeString is the default flag type. Its value is a string.
	FlagTypeString = "string"
	// FlagTypeBool is a boolean flag.
	FlagTypeBool = "bool"
	// FlagTypeInt is an integer flag. Its value is a Go int in templates and scripts.
	FlagTypeInt = "int"
)

Supported values of a custom command flag's `type:`.

Variables

This section is empty.

Functions

func DecodeArguments

func DecodeArguments(encoded string) (args []string, ok bool, err error)

DecodeArguments is the inverse of EncodeArguments. It returns ok=false when encoded is empty, which means no arguments were ever recorded.

func EffectiveFlagType

func EffectiveFlagType(flag *schema.CommandFlag) string

EffectiveFlagType returns the flag's type, treating an empty type as the default string type.

func EncodeArguments

func EncodeArguments(args []string) (string, error)

EncodeArguments serializes resolved arguments losslessly so they can travel through a string-valued map (such as cobra command annotations) without being split on any character.

func IntFlagDefault

func IntFlagDefault(flag *schema.CommandFlag) (int, error)

IntFlagDefault returns the default of an int flag. A flag with no default is 0. The YAML default may be an integer, a whole-number float, or a numeric string.

func ParseIntFlagValue

func ParseIntFlagValue(name, value string) (int, error)

ParseIntFlagValue converts the string form of an int flag value into an int.

func ResolveArguments

func ResolveArguments(declared []schema.CommandArgument, supplied []string) ([]string, error)

ResolveArguments merges the positional values supplied on the command line with the declared arguments. The result has one entry per declared argument, in declaration order.

A declared argument that was not supplied takes its default. An argument with no default that is not required resolves to an empty string; a required argument with no default is an error.

func SupportedFlagTypes

func SupportedFlagTypes() []string

SupportedFlagTypes lists the accepted values of a flag's `type:`, in documentation order.

func ValidateFlag

func ValidateFlag(commandName string, flag *schema.CommandFlag) error

ValidateFlag fails when the flag declares a type Atmos does not support, or a combination of options that cannot work for that type. Custom commands call it at registration, so a typo in atmos.yaml fails loudly instead of quietly registering a string flag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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