Documentation
¶
Overview ¶
Package variables contains functions for interacting with variables
Index ¶
- type ExtraVariableInfo
- type InteractiveVariable
- type SetVariable
- type SetVariableMap
- type Variable
- type VariableConfig
- func (vc *VariableConfig[T]) CheckVariablePattern(name string) error
- func (vc *VariableConfig[T]) GetSetVariable(name string) (variable *SetVariable[T], ok bool)
- func (vc *VariableConfig[T]) GetSetVariables() SetVariableMap[T]
- func (vc *VariableConfig[T]) PopulateVariables(variables []InteractiveVariable[T], presetVariables map[string]string) error
- func (vc *VariableConfig[T]) SetVariable(name, value, pattern string, extra T)
- type VariableType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtraVariableInfo ¶
type ExtraVariableInfo struct {
}
ExtraVariableInfo carries any additional information that may be desired through variables passed and set by actions (available to library users).
type InteractiveVariable ¶
type InteractiveVariable[T any] struct { Variable[T] `json:",inline"` Description string `` /* 126-byte string literal not displayed */ Default string `json:"default,omitempty" jsonschema:"description=The default value to use for the variable"` Prompt bool `json:"prompt,omitempty" jsonschema:"description=Whether to prompt the user for input for this variable"` }
InteractiveVariable is a variable that can be used to prompt a user for more information
type SetVariable ¶
type SetVariable[T any] struct { Variable[T] `json:",inline"` Value string `json:"value" jsonschema:"description=The value the variable is currently set with"` }
SetVariable tracks internal variables that have been set during this execution run
type SetVariableMap ¶
type SetVariableMap[T any] map[string]*SetVariable[T]
SetVariableMap represents a map of variable names to their set values
type Variable ¶
type Variable[T any] struct { Name string `json:"name" jsonschema:"description=The name to be used for the variable,pattern=^[A-Z0-9_]+$"` Pattern string `` /* 150-byte string literal not displayed */ Extra T `json:",omitempty,inline"` }
Variable represents a variable that has a value set programmatically
type VariableConfig ¶
type VariableConfig[T any] struct { // contains filtered or unexported fields }
VariableConfig represents a value to be templated into a text file.
func New ¶
func New[T any](prompt func(variable InteractiveVariable[T]) (value string, err error), logger *slog.Logger) *VariableConfig[T]
New creates a new VariableConfig
func (*VariableConfig[T]) CheckVariablePattern ¶
func (vc *VariableConfig[T]) CheckVariablePattern(name string) error
CheckVariablePattern checks to see if a current variable is set to a value that matches its pattern
func (*VariableConfig[T]) GetSetVariable ¶
func (vc *VariableConfig[T]) GetSetVariable(name string) (variable *SetVariable[T], ok bool)
GetSetVariable gets a variable set within a VariableConfig by its name
func (*VariableConfig[T]) GetSetVariables ¶
func (vc *VariableConfig[T]) GetSetVariables() SetVariableMap[T]
GetSetVariables gets the variables set within a VariableConfig
func (*VariableConfig[T]) PopulateVariables ¶
func (vc *VariableConfig[T]) PopulateVariables(variables []InteractiveVariable[T], presetVariables map[string]string) error
PopulateVariables handles setting the active variables within a VariableConfig's SetVariableMap
func (*VariableConfig[T]) SetVariable ¶
func (vc *VariableConfig[T]) SetVariable(name, value, pattern string, extra T)
SetVariable sets a variable in a VariableConfig's SetVariableMap
type VariableType ¶
type VariableType string
VariableType represents a type of a variable
const ( // RawVariableType is the default type for a variable RawVariableType VariableType = "raw" // FileVariableType is a type for a variable that loads its contents from a file FileVariableType VariableType = "file" )