Documentation ¶
Index ¶
- type Config
- type ConfigFile
- type File
- type FileMetadata
- type InputCtx
- type Root
- type Variable
- type Variables
- func (vv Variables) AddToCtx(prefix string, ctx map[string]interface{})
- func (vv Variables) Ctx() map[string]interface{}
- func (vv *Variables) FillPrompt(prefix string, ctx InputCtx)
- func (vv Variables) FindNamed(s string) *Variable
- func (vv Variables) FindWithParent(p *Variable, s string) *Variable
- func (vv *Variables) FromMapSlice(in yaml.MapSlice)
- func (vv Variables) Prompt()
- func (vv *Variables) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Delimiters []string `yaml:"delimiters"` Copy *bool `yaml:"copy"` Ignore *bool `yaml:"ignore"` Variables *Variables `yaml:"variables"` If string `yaml:"if"` Ctx InputCtx `yaml:"-"` }
Config is a configuration that can be applied to a single file (inline conf) or to an entire directory
type ConfigFile ¶
ConfigFile is the combination of File and Config
func NewConfigFile ¶
func NewConfigFile(path string, file os.FileInfo, ctx InputCtx) *ConfigFile
NewConfigFile returns a new configfile
func (*ConfigFile) Prompt ¶
func (c *ConfigFile) Prompt()
Prompt will prompt the necessary prompts wihtout displaying the ones for variables that were already defined in the input file
type File ¶
type File struct { Path string Dir string NewPath string Info os.FileInfo Renderers []*ConfigFile Metadata *FileMetadata Ctx InputCtx }
File represents a single file, combining both its path and its os.FileInfo
func (*File) AddRenderer ¶
func (f *File) AddRenderer(c *ConfigFile)
AddRenderer adds a renderer to a file
func (*File) ParseFrontMatter ¶
ParseFrontMatter will parse the front matter and add a renderer to the file if needed
type FileMetadata ¶ added in v1.4.0
type InputCtx ¶
type InputCtx yaml.MapSlice
InputCtx is the input context
func GetInputContext ¶
GetInputContext will return a map of string to interface{} that will then be used to determine whether or not a value from the root config file has already been filled
func GetSetContext ¶
GetSetContext will return the map of string to interface{} that contains the set flags passed on the command line parsed
type Root ¶
type Root struct { ConfigFile `yaml:",inline"` Name string `yaml:"name"` Version string `yaml:"version"` Description string `yaml:"description"` }
Root is a ConfigFile with extra information. It should be located at the root of the template
func NewRootConfig ¶
NewRootConfig will return the root configuration
type Variable ¶
type Variable struct { // Default value to display to the user for input prompts Default string `yaml:"default"` // Prompt allows to override the standard prompt and display more info CustomPrompt string `yaml:"prompt"` // List of possible values for the user to answer Values []string `yaml:"values"` // If this field isn't empty, then an help message can be shown to the user Help string `yaml:"help"` // Flags a variable as required, preventing the user from entering empty // values Required bool `yaml:"required"` // Confirm is used both for default variable and to store the result. // If this field isn't nil, then a confirmation survey is used. Confirm *bool `yaml:"confirm,omitempty"` Variables Variables `yaml:"variables,omitempty"` Result string Name string }
Variable represents a single variable
func (*Variable) FillFromMapItem ¶
FillFromMapItem fills the value not from prompt but from a mapitem
func (*Variable) FromMapItem ¶
FromMapItem will fill the variable with the data stored in the input yaml.MapItem. Used to recursively parse nested variables.
type Variables ¶
type Variables []*Variable
Variables is a slice of pointer to a single variable
func (*Variables) FillPrompt ¶
FillPrompt will fill the variables from the input context if needed
func (Variables) FindNamed ¶
FindNamed will find a variable by name in the global variables. Returns nil if not found
func (Variables) FindWithParent ¶
FindWithParent tries to find the variable with a prefix
func (*Variables) FromMapSlice ¶
FromMapSlice fills in the Variables struct with the data stored in a yaml.MapSlice. Used to recursively parse nested variables.
func (*Variables) UnmarshalYAML ¶
UnmarshalYAML defines a custom way to unmarshal to the Variables type. Specifically this allows to conserve the key order