templates

package
v0.0.0-...-078a86d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDirectory

func CopyDirectory(src string, dest string, ignorePaths []string) error

CopyDirectory copies a directory recursively with options to specify directories and files to ignore.

func CustomTxtFuncMap

func CustomTxtFuncMap(tmpl *template.Template) template.FuncMap

TxtCustomFuncMap returns a FuncMap with the custom functions used in the templates. You can implement your own custom functions inside of this func.

func DeleteIgnoredFiles

func DeleteIgnoredFiles(directoryPath string, ignorePaths []string) error

DeleteIgnoredFiles recursively walks through a directory and its subdirectories specified by 'directoryPath'. It deletes files and directories that match any of the patterns in 'ignorePaths'. Additionally, it deletes files and directories starting with "_" (Ignore Prefix), which are files that should be processed by Cloney but not copied when the template is cloned.

func GetAllDirectoryPaths

func GetAllDirectoryPaths(directoryPath string, ignorePaths []string) ([]string, error)

GetAllDirectoryPaths returns a list of all directory paths within a directory and its subdirectories, with options to specify directories and files to ignore.

func GetAllFilePaths

func GetAllFilePaths(directoryPath string, ignorePaths []string) ([]string, error)

GetAllFilePaths returns a list of all file paths within a directory and its subdirectories, with options to specify directories and files to ignore.

func ShouldIgnorePath

func ShouldIgnorePath(baseDirectory string, path string, ignorePaths []string) (bool, error)

ShouldIgnorePath determines whether a given file or directory path should be ignored based on a list of patterns within a specified base directory. It returns true if the path should be ignored according to any of the provided patterns, and false otherwise.

func WatchDirectory

func WatchDirectory(watcher *fsnotify.Watcher, directoryPath string, ignorePaths []string, onChange func()) error

WatchDirectory monitors a directory and its subdirectories for changes, including create, write, remove, rename, and chmod events. It receives a function that is called when any of these events are detected.

Parameters:

watcher:      An initialized fsnotify.Watcher.
directoryPath: The path of the directory to watch.
ignorePaths:  An optional list of file paths to ignore during monitoring.
onChange:     A callback function to execute when any valid event is detected.

Returns an error if any issues occur during setup or monitoring.

Types

type TemplateFiller

type TemplateFiller struct {
	// Variables contains the variables to be injected into the template.
	Variables map[string]interface{}
}

TemplateFiller is a struct used for populating Go templates with variables.

func NewTemplateFiller

func NewTemplateFiller(variablesMap map[string]interface{}) *TemplateFiller

NewTemplateFiller creates a new TemplateFiller instance initialized with the provided variables.

func (*TemplateFiller) FillDirectory

func (t *TemplateFiller) FillDirectory(src string, ignorePaths []string, outputInTerminal bool) error

FillDirectory processes template files in a source directory, replacing placeholders with variables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL