Documentation ¶
Index ¶
- func ComputeBaseDirectory(file string, allFiles []string, baseDirectory string) string
- type Option
- func WithAllowProgramCreation(allowProgramCreation bool) Option
- func WithDelimiters(leftDelimiter string, rightDelimiter string) Option
- func WithGoTemplate(withGoTemplate bool) Option
- func WithMasks(masks ...string) Option
- func WithPrograms(programs map[string]*cliopatra.Program) Option
- func WithRenameOutputFiles(renameOutputFiles map[string]string) Option
- func WithRepositories(repositories ...Repository) Option
- func WithVerbose(verbose bool) Option
- func WithYamlMarkers(withYamlMarkers bool) Option
- type Renderer
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeBaseDirectory ¶
ComputeBaseDirectory computes the base directory for the given file. If baseDirectory is not empty, it is returned. Otherwise, the base directory is computed by finding the shortest common prefix of the given file and all files.
Input directories have to end with a slash, as they will otherwise be considered files and stripped of their last component.
The returned base directory won't have a / at the end.
Types ¶
type Option ¶
type Option func(r *Renderer)
func WithDelimiters ¶
func WithGoTemplate ¶
func WithRenameOutputFiles ¶
func WithRepositories ¶
func WithRepositories(repositories ...Repository) Option
func WithVerbose ¶
func WithYamlMarkers ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders recursive templates by exposing cliopatra specific template functions.
NOTE(manuel, 2023-03-19) This could actually be a generic component that can be used for arbitrary recursive watching and rendering of templates See https://github.com/go-go-golems/glazed/issues/223
func NewRenderer ¶
func (*Renderer) CreateTemplate ¶
CreateTemplate creates a standard glazed template (meaning, with all the sprig functions and co) and registers a set of custom functions to run and modify cliopatra programs.
These functions are
`lookup`: looks up a program by name and returns it
`program`: creates a new program. This will fail if program creation is not allowed.
`path`: sets the path of a program
`verbs`: sets the verbs of a program (a []string)
`env`: sets the env of a program (a map[string]string)
`add_raw_flag`: adds a raw flag to a program (a string)
`raw_flags`: sets the raw flags of a program (a []string)
`flag`: sets the value of a flag (a interface{})
`flag_raw`: sets the raw value of a flag (a string)
`arg`: sets the value of an arg (a interface{})
`arg_raw`: sets the raw value of an arg (a string)
`run`: runs a program and returns the output. It can take an arbitrary number of options.
If the program to be run is a string, it will be looked up in the programs passed to the renderer. If it is a *pkg.Program, it will be run as is.
If a string is passed as an option, it will be appended to the program as a raw flag.
`run` clones the program before modifying it with the passed options.
func (*Renderer) Render ¶
Render renders the template from the given reader and writes the result to the given writer.