Documentation
¶
Index ¶
- Variables
- func ListGlobals() error
- func ListPropertyFormats()
- func ParseJson(data []byte) (map[string]any, error)
- func ParseUsage(data []byte, startPrefix string, usage map[string]string)
- func ParseYaml(data []byte) (map[string]any, error)
- func SetParser(name string, parse PropertyParser)
- type BaseConfig
- type Config
- type Funcs
- type Options
- type PropertyParser
- type TemplateOp
- type TemplateSet
Constants ¶
This section is empty.
Variables ¶
var TraceFuncs bool
Functions ¶
func ListGlobals ¶ added in v0.2.0
func ListGlobals() error
func ListPropertyFormats ¶ added in v0.2.0
func ListPropertyFormats()
func ParseUsage ¶
ParseFuncUsage parses function usage in the format
name1
description ...
name2
...
There may be additional indentation. This is the format used by "go doc text/template", under "Predefined global functions..."
if startPrefix is not empty, the parsing begins after the first line that begins with startPrefix, and ends at the first line that does not start with white space.
func SetParser ¶ added in v0.2.0
func SetParser(name string, parse PropertyParser)
Types ¶
type BaseConfig ¶ added in v0.2.0
type BaseConfig struct {
Funcs Funcs
Templates []TemplateSet
Properties map[string]any
}
func (*BaseConfig) CreateModel ¶ added in v0.2.0
func (t *BaseConfig) CreateModel() map[any]any
func (*BaseConfig) SetFunc ¶ added in v0.2.0
func (t *BaseConfig) SetFunc(name string, f any)
func (*BaseConfig) SetProperty ¶ added in v0.2.0
func (t *BaseConfig) SetProperty(name string, value any)
type Config ¶ added in v0.2.0
type Config struct {
BaseConfig
// contains filtered or unexported fields
}
Programmatic configuration of templates Use to add funcs to the FuncMap
func (*Config) AddUsageTxt ¶ added in v0.2.0
Add usage for functions, in text format The usage is parsed when needed
type Funcs ¶ added in v0.2.0
Funcs is used to create a template.FuncMap If a value is a function, it is copied as is to the FuncMap. Otherwise, it is converted to a func that returns it.
func (Funcs) CreateFuncMap ¶ added in v0.2.0
Generate a template.FuncMap
type Options ¶
type Options struct {
PropertyFiles []string `name:"f" usage:"properties file"`
Format string `name:"format" usage:"property file format"`
KeyValues []string `name:"D" usage:"key=value - set a property"`
// if FS is not null, read files from FS, otherwise use os.ReadFile()
// used for testing
FS fs.FS
}
func (*Options) ParseKeyValue ¶
ParseKeyValue - parse a string of the form <key1[.key2]...>=<value> The keys are separated by dots The first returned argument is the keys, and the second is the value If there is no "=", then the keys are nil and the value is the input string
type TemplateOp ¶
type TemplateOp struct {
Base BaseConfig `name:"-"`
TemplateName string `name:"t" usage:"template name or file"`
OutputFile string `name:"o" usage:"output file"`
FileMode string `name:"mode" usage:"output file mode"`
Delims string `name:"delims" usage:"template left,right delims, separated by ','"`
Options
// contains filtered or unexported fields
}
func (*TemplateOp) Configured ¶
func (t *TemplateOp) Configured() error
func (*TemplateOp) Init ¶
func (t *TemplateOp) Init() error
func (*TemplateOp) ListProperties ¶ added in v0.2.0
func (t *TemplateOp) ListProperties() error
func (*TemplateOp) ListTemplates ¶
func (t *TemplateOp) ListTemplates(args ...string) error
func (*TemplateOp) Run ¶
func (t *TemplateOp) Run(args ...string) error
type TemplateSet ¶ added in v0.2.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli implement a Command Line Interface, using melato.org/command.
|
Package cli implement a Command Line Interface, using melato.org/command. |
|
package funcs provides example functions that you can add to the templates
|
package funcs provides example functions that you can add to the templates |