Documentation ¶
Overview ¶
Package stencil implements a template package manager.
Index ¶
- Constants
- func BaseDir() (string, error)
- func Untar(src io.Reader, visit func(string, func() io.ReadCloser) error) error
- func Unzip(src io.Reader, visit func(string, func() io.ReadCloser) error) error
- type Binary
- type ConsolePrompt
- type Env
- type FS
- type FileArchiveObj
- type FileObj
- type FileSystem
- type Logger
- type Markdown
- type Objects
- type Prompter
- type Stencil
- type Vars
Constants ¶
const MaxFileSize = 1000000
MaxFileSize specifies the max file size in the cache.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Binary ¶ added in v0.0.2
type Binary struct {
*Stencil
}
Binary implements managing binaries.
func (*Binary) CopyFromArchive ¶ added in v0.0.2
CopyFromArchive copies a file from an archive at the url. CopyFromArchive supports .tar, .tar.gz and .zip extensions for the archive.
func (*Binary) CopyManyFromArchive ¶ added in v0.0.2
CopyManyFromArchive extracts multiple files from an archive at the url. CopyManyFromArchive supports .tar, .tar.gz and .zip extensions for the archive. The glob pattern can be used to specify what files need to be extracted. See https://github.com/bmatcuk/doublestar for the set of allowed glob patterns. The destination is considered a folder.
type ConsolePrompt ¶ added in v0.0.2
ConsolePrompt implements the prompter interface.
func (*ConsolePrompt) PromptBool ¶ added in v0.0.2
func (c *ConsolePrompt) PromptBool(prompt string) (bool, error)
Bool prompts for and fetches a bool.
func (*ConsolePrompt) PromptString ¶ added in v0.0.2
func (c *ConsolePrompt) PromptString(prompt string) (string, error)
String prompts for and fetches a string.
type Env ¶ added in v0.0.2
type Env struct{}
Env implements some standard environent accessors for stencil.
type FS ¶
FS implements a FileSystem interface.
type FileArchiveObj ¶ added in v0.0.2
FileArchiveObj tracks an archive.
type FileObj ¶ added in v0.0.2
type FileObj struct {
Loc, URL string
}
FileObj tracks a single file copied locally.
type FileSystem ¶
type FileSystem interface { Read(path string) ([]byte, error) Write(path string, data []byte, mode os.FileMode) error Remove(path string) error RemoveAll(path string) error }
FileSystem is the generic file system used by stencil. Use FS{} or a custom implementation.
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is the interface used by stencil to log messages.
Use log.New(...) to create an appropriate logger.
type Markdown ¶ added in v0.0.2
type Markdown struct {
*Stencil
}
Markdown implements the markdown functionality.
func (*Markdown) CopyMarkdownSnippets ¶ added in v0.0.2
CopyMarkdownSnippets first treats the url as a markdown stripping out everything but code fences with names matching the provided regex. The name of the code fence is the first word after the triple backquote.
Note that standard go templates are still executed on top of this so the embedded code can use any stencil function.
type Objects ¶ added in v0.0.2
type Objects struct { *Stencil `json:"-"` Before *Objects `json:"-"` Pulls map[string]bool Files map[string]*FileObj FileArchives map[string]*FileArchiveObj Bools map[string]bool Strings map[string]string }
Objects tracks a collection of objects
func (*Objects) LoadObjects ¶ added in v0.0.2
LoadObjects loads all the objects from the .stencil directory.
func (*Objects) SaveObjects ¶ added in v0.0.2
SaveObjects saves all the objects to the .stencil directory.
type Prompter ¶ added in v0.0.2
type Prompter interface { PromptBool(prompt string) (bool, error) PromptString(prompt string) (string, error) }
Prompter is the generic interface to prompt and fetch info interactively.
type Stencil ¶
type Stencil struct { State map[string]interface{} Funcs map[string]interface{} Printf func(format string, v ...interface{}) Errorf func(format string, v ...interface{}) error FileSystem Prompter Env Binary Objects Vars Markdown }
Stencil maintains all the state for managing a single directory.
func New ¶
func New(verbose, errorl Logger, p Prompter, fs FileSystem) *Stencil
New creates a new stencil manager.
type Vars ¶
type Vars struct { *Stencil BoolDefs map[string]string StringDefs map[string]string // contains filtered or unexported fields }
Vars holds named values.
func (*Vars) DefineBool ¶
DefineBool defines a boolean variable name.
func (*Vars) DefineString ¶ added in v0.0.2
DefineString defines a string variable name.
func (*Vars) VarBool ¶
VarBool fetches the value for the named boolean. If the value is not present either via --var or via a previous invocation, the value is prompted for using the prompt in the definition. Any --var use overrides default values present from previous invocations.
func (*Vars) VarString ¶ added in v0.0.2
VarString fetches the value for the named variable. If the value is not present either via --var or via a previous invocation, the value is prompted for using the prompt in the definition. Any --var use overrides default values present from previous invocations.