Documentation
¶
Index ¶
- Variables
- func BuildTemplate(text string, sharedTemplateBuffers []*bytes.Buffer, name string) (*template.Template, error)
- func CheckIfFile(path string) (bool, error)
- func CmpStringLength(a, b string) int
- func CountRecursables(paths []string) (int, error)
- func Exists(path string) (bool, error)
- func GenerateTempDirName(pattern string) (string, error)
- func GetDataFromPath(source, arg string, settings *YutcSettings) (*bytes.Buffer, error)
- func GetDataFromReadCloser(f io.ReadCloser) (*bytes.Buffer, error)
- func GetVersion() string
- func InitLogger(levelOverride string)
- func IsArchive(filePath string) bool
- func IsDir(path string) (bool, error)
- func LoadSharedTemplates(templates []string) []*bytes.Buffer
- func LoadTemplates(templateFiles []string, sharedTemplateBuffers []*bytes.Buffer) ([]*template.Template, error)
- func MergeData(dataFiles []string) (map[string]any, error)
- func NormalizeFilepath(file string) string
- func ParseFileStringFlag(v string) (string, error)
- func PrintVersion()
- func ReadTar(filePath string) ([]filePathMap, error)
- func ReadUrl(templatePath string) (string, []byte, string, error)
- func ValidateArguments(settings *YutcSettings) (code int, errs []error)
- func WalkDir(rootPath string) []string
- type HttpStatusError
- type YutcSettings
Constants ¶
This section is empty.
Variables ¶
var ExitCode = new(int)
var ExitCodeMap = map[string]int{
"ok": mustParseInt("0"),
"output file is a directory": mustParseInt("1"),
"cannot use `stdout` with multiple template files": mustParseInt("10"),
"file exists and `overwrite` is not set": mustParseInt("100"),
"cannot use stdin with multiple files": mustParseInt("1000"),
"cannot use `overwrite` with `stdout`": mustParseInt("10000"),
"input file does not exist": mustParseInt("100000"),
"cannot use both a pattern match and file input": mustParseInt("1000000"),
"folder/tar files as inputs must be the only ones": mustParseInt("10000000"),
}
var Fs = afero.NewOsFs()
var YutcLog zerolog.Logger
Functions ¶
func BuildTemplate ¶
func CheckIfFile ¶ added in v0.1.0
CheckIfFile checks if a path is a file, returns a bool pointer and an error if doesn't exist
func CmpStringLength ¶ added in v0.1.0
func CountRecursables ¶ added in v0.1.0
func Exists ¶ added in v0.1.0
Exists checks if a path exists, returns a bool pointer and an error if doesn't exist
func GenerateTempDirName ¶ added in v0.1.0
GenerateTempDirName generates a temporary directory name, basically just standard's MktempDir's without the create
func GetDataFromPath ¶
func GetDataFromPath(source, arg string, settings *YutcSettings) (*bytes.Buffer, error)
GetDataFromPath reads from a file, URL, or stdin and returns a buffer with the contents
func GetDataFromReadCloser ¶
func GetDataFromReadCloser(f io.ReadCloser) (*bytes.Buffer, error)
GetDataFromReadCloser reads from a ReadCloser and returns a buffer with the contents
func GetVersion ¶ added in v0.0.5
func GetVersion() string
func InitLogger ¶ added in v0.0.3
func InitLogger(levelOverride string)
func IsDir ¶ added in v0.1.0
IsDir checks if a path is a directory, returns a bool pointer and an error if doesn't exist
func LoadSharedTemplates ¶
LoadSharedTemplates reads from a list of shared template files and returns a list of buffers with the contents
func LoadTemplates ¶
func MergeData ¶
MergeData merges data from a list of data files and returns a map of the merged data. The data is merged in the order of the data files, with later files overriding earlier ones. Supports files supported by ParseFileStringFlag.
func NormalizeFilepath ¶ added in v0.1.0
func ParseFileStringFlag ¶
ParseFileStringFlag determines the source of a file string flag based on format and returns the source as a string, or an error if the source is not supported. Currently, supports "file", "url", and "stdin" (as `-`).
func PrintVersion ¶
func PrintVersion()
func ValidateArguments ¶
func ValidateArguments(settings *YutcSettings) (code int, errs []error)
ValidateArguments checks the arguments for the CLI and returns a code for the error
Types ¶
type HttpStatusError ¶ added in v0.1.0
func NewHttpStatusError ¶ added in v0.1.0
func NewHttpStatusError(resp *http.Response) *HttpStatusError
func (*HttpStatusError) Error ¶ added in v0.1.0
func (e *HttpStatusError) Error() string
func (*HttpStatusError) StatusText ¶ added in v0.1.0
func (e *HttpStatusError) StatusText() string
type YutcSettings ¶ added in v0.1.0
type YutcSettings struct { DataFiles []string `json:"data-files"` CommonTemplateFiles []string `json:"common-templates"` TemplatePaths []string `json:"template-files"` Output string `json:"output"` IncludeFilenames bool `json:"include-filenames"` Overwrite bool `json:"overwrite"` Version bool `json:"version"` Verbose bool `json:"verbose"` BearerToken string `json:"bearer-auth"` BasicAuth string `json:"basic-auth"` }
YutcSettings is a struct to hold all the settings from the CLI
func NewCLISettings ¶ added in v0.1.0
func NewCLISettings() *YutcSettings