Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SkipErrors ¶ added in v0.2.0
func SkipErrors(r *Runner)
Types ¶
type BlueprintParser ¶
type FileTreeReader ¶ added in v0.2.0
type FileTreeReader interface { // ReadFile reads the file from file tree named by filename and returns // the contents. ReadFile(filename string) ([]byte, error) // Walk walks the file tree, calling walkFn for each file or directory // in the tree, including root. All errors that arise visiting files // and directories are filtered by walkFn. Walk(walkFn func(filepath string, isDir bool, err error) error) error }
FileTreeReader is an abstraction over any system-agnostic file tree. In the case of generator, it provides full structure, that should be scanned, read and generated at the filepath relative to the working directory.
type Filesystem ¶
type Logger ¶ added in v0.2.0
type Logger interface { Debug(v ...interface{}) Info(v ...interface{}) }
type OnErrorFn ¶
OnErrorFn is called if error occurred when processing file. Return true to skip the file and continue process, or false to terminate Runner and return the error.
type OnExistsFn ¶
OnExistsFn handles files that already exist at target path. Return true to overwrite file or false to skip it.
type OnSuccessFn ¶
type OnSuccessFn func(src, dst string)
OnSuccessFn is called on each successfully generated file. First argument holds path of the source file, and second argument - path of the generated file.
type OptionFn ¶ added in v0.2.0
type OptionFn func(*Runner)
func IgnorePath ¶ added in v0.2.0
func OnFileExists ¶
func OnFileExists(fn OnExistsFn) OptionFn
func WithLogger ¶ added in v0.2.0
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(fs Filesystem, bp BlueprintParser, dir string, options ...OptionFn) *Runner
func (*Runner) Run ¶
func (r *Runner) Run(ftr FileTreeReader) error
Run generates all the files from FileTreeReader by walking over each file, reading it and writing it at relative path in working directory. If file ends with extension `.accio`, then it's parsed with BlueprintParser, which returns file's content and additional metadata, like custom filepath, and whether file should be skipped.