Documentation
¶
Overview ¶
Package exec implements boil's exec command.
Index ¶
- func Run(config *Config) (err error)
- type Config
- type Execute
- type PresentPromptFunc
- type Task
- type Tasks
- func (self Tasks) CheckForTargetConflicts() (err error)
- func (self Tasks) ExecPostExecuteActions(data *boil.Data) (err error)
- func (self Tasks) ExecPreExecuteActions(data *boil.Data) (err error)
- func (self Tasks) ExecPreParseActions() (err error)
- func (self Tasks) Execute(state *state, print bool) (err error)
- func (self Tasks) PresentPrompts(state *state, cb PresentPromptFunc) (err error)
- func (self Tasks) Print(wr io.Writer)
- func (self Tasks) SetTargetsFromState(state *state) (err error)
- func (self Tasks) Validate(state *state) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// TemplatePath is the source template path. During Run() it is adjusted to
// an absolute path to the Template either inside or outside of repository.
//
// If the path is rooted, i.e. starts with "/" the path is treated as an
// absolute path to a Template and no repository is being loaded or used.
//
// If the path is not rooted, the path is treated as a path to a Template
// relative to the loaded repository.
//
// If TemplatePath is an absolute filesystem path it is adjusted to an
// empty string during Run().
TemplatePath string
// OutputDir is the output directory where Template will be executed.
// If the value is empty the Template will be executed in the current
// working directory
//
// TargetPath is adjusted to an absolute path of OutputDir during Run().
OutputDir string
// Overwrite, if true specifies that any file matching a Template output
// file already existing in the target directory may be overwritten without
// prompting the user or generating an error.
Overwrite bool
// NoExecute if true will not execute any write operations and will
// instead print out the operations like boil.Config.Verbose was enabled.
NoExecute bool
// NoPrompts if true disables prompting the user for variables and will
// return an error if a variable declared in a prompt was not parsed from
// the command line.
NoPrompts bool
// NoMetadata if true disables parsing template metadata and copies the
// source template files recursively to output directory. This disables
// groups and prompts but the variable system still works via command line.
NoMetadata bool
// EditAfterExec if true opens the output with the editor.
EditAfterExec bool
// GoInputs is a list of paths of go files or packages to parse and make
// their AST available to template files.
GoInputs []string
// JsonInputs is a list of paths of json files to parse and make available
// to template files.
JsonInputs []string
// Vars are variables given by the user on command line.
// These variables will be available via .Vars template field.
Vars boil.Variables
// Config is the loaded program configuration.
Config *boil.Config
}
Config is the Exec command configuration.
func (*Config) GetRepositoryPath ¶
GetRepositoryPath returns the RepositoryPath considering override values.
func (*Config) ShouldPrint ¶
ShouldPrint returns true if Config.Verbose or Config.NoExecute is true.
type Execute ¶
type Execute struct {
// Path is the path to the template directory relative to repository root.
Path string
// Source is path of the template file or dir relative to repo root.
Source string
// Target is the absolute path of the target file which will contain Source
// template output. If the source path had placeholder values they will be
// replaced with actual values to generate output filenames.
Target string
// IsDir wil be true if Source is a directory.
IsDir bool
}
Execute defines an execution action as part of a exec command task.
type Task ¶
type Task struct {
// Metafile is the Template Metafile.
Metafile *boil.Metafile
// List is a list of actions to be performed for this template.
List []*Execute
}
Task defines an execution task to perform for a template.
type Tasks ¶
type Tasks []*Task
Tasks is a list of Task.
func (Tasks) CheckForTargetConflicts ¶
CheckForTargetConflicts returns nil if none of the Target paths of all defined Tasks in self do not point to an existing file. Otherwise a descriptive error is returned.
func (Tasks) ExecPostExecuteActions ¶
ExecPostExecuteActions executes all PostExecute actions defined in all metafiles in the order they are defined, depth first. The first error that occurs from any action is returned and execution stopped or nil if everything successed.
func (Tasks) ExecPreExecuteActions ¶
ExecPreExecuteActions executes all PreExecute actions defined in all metafiles in the order they are defined, depth first. The first error that occurs from any action is returned and execution stopped or nil if everything successed.
func (Tasks) ExecPreParseActions ¶
ExecPreParseActions executes all PreParse actions defined in all metafiles in the order they are defined, depth first. The first error that occurs from any action is returned and execution stopped or nil if everything successed.
func (Tasks) PresentPrompts ¶
func (self Tasks) PresentPrompts(state *state, cb PresentPromptFunc) (err error)
PresentPrompts presents a prompt to the user on command line for each of the prompts defined in metafiles of all tasks in self, in order as they appear in self, depth first. If undeclaredOnly is true only prompts for entries not found in variables are presented.
Values are stored in variables under names of Variables they prompt for. If undeclaredOnly is true, a variable already defined in variables will not be prompted for.
func (Tasks) SetTargetsFromState ¶
SetTargetsFromState expands template tokens in each execution.Target of self and determines the absolute path of each in the output directory. Returns an error if one occurs or nil.