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
- func DecodeArguments(encoded string) (args []string, ok bool, err error)
- func EffectiveFlagType(flag *schema.CommandFlag) string
- func EncodeArguments(args []string) (string, error)
- func IntFlagDefault(flag *schema.CommandFlag) (int, error)
- func ParseIntFlagValue(name, value string) (int, error)
- func ResolveArguments(declared []schema.CommandArgument, supplied []string) ([]string, error)
- func SupportedFlagTypes() []string
- func ValidateFlag(commandName string, flag *schema.CommandFlag) error
Constants ¶
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 ¶
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 ¶
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 ¶
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.