Documentation ¶
Index ¶
- func CalculateChecksumF(path models.Path) (string, error)
- func CalculateChecksumS(s string) string
- func CloneGitRepository(url string, p models.Path, cloneDirName string, liveOutput func(string)) error
- func CreatePrefixedTempFile(dir models.Path, prefix string) (models.Path, error)
- func CreateTempDir() (models.Path, error)
- func CreateTempFile(dir models.Path) (models.Path, error)
- func FmtTree(config FmtTreeConfig, nodes ...Node) string
- func GetGitFetchHead(d models.Path) (string, string, error)
- func GetGitHasUnpublishedChanges(d models.Path) (bool, error)
- func GetGitHasUntrackedChanges(d models.Path) (bool, error)
- func GetGitRemoteUrl(d models.Path) (string, error)
- func GetGitRootDirectory(d models.Path) (string, error)
- func GetGitVersion() (string, error)
- func GitCheckout(repository models.Path, ref string) error
- func GitPull(repository models.Path, liveOutput func(string)) error
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func ReadFileToStr(path models.Path) (string, error)
- func RunCommand(d models.Path, command string, args ...string) (string, string, error)
- func RunCommandCombinedOutput(d models.Path, command string, args ...string) (string, error)
- func RunCommandLiveOutput(fStdout func(string), fStderr func(string), wd models.Path, command string, ...) error
- func RunCommandLiveOutputCombinedOutput(fStdout func(string), wd models.Path, command string, args ...string) error
- func StringInsert(original string, insert string, startDelimiter string, endDelimiter string) (string, error)
- func StringInsertAtFirst(original string, insert string, startDelimiter string, endDelimiter string) (string, error)
- func WriteStrToFile(path models.Path, str string) error
- type FmtTreeConfig
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateChecksumF ¶ added in v0.0.2
CalculateChecksumF calculates the checksum of a given file.
func CalculateChecksumS ¶ added in v0.0.2
CalculateChecksumS calculates the checksum of a given string.
func CloneGitRepository ¶
func CloneGitRepository(url string, p models.Path, cloneDirName string, liveOutput func(string)) error
CloneGitRepository clones a remote git repository.
func CreatePrefixedTempFile ¶ added in v0.0.2
CreatePrefixedTempFile creates a temporary file using os.CreateTemp.
func CreateTempDir ¶
CreateTempDir creates a temporary directory using os.MkdirTemp.
func CreateTempFile ¶
CreateTempFile creates a temporary file using os.CreateTemp.
func FmtTree ¶
func FmtTree(config FmtTreeConfig, nodes ...Node) string
FmtTree formats an array of Node to output an ordered information tree. Allows nesting of Node.
func GetGitFetchHead ¶
GetGitFetchHead retrieves the current HEAD of a local repository. Returns long commit hash, commit abbreviation and/or error.
func GetGitHasUnpublishedChanges ¶
GetGitHasUnpublishedChanges returns whether a local repository has unpushed commits. In case of any errors, true is returned.
func GetGitHasUntrackedChanges ¶
GetGitHasUntrackedChanges returns whether a local repository has uncommitted changes. In case of any errors, true is returned.
func GetGitRemoteUrl ¶
GetGitRemoteUrl retrieves the remote url from a git directory tree.
func GetGitRootDirectory ¶
GetGitRootDirectory retrieves the root of a git directory tree.
func GetGitVersion ¶
GetGitVersion retrieves the git version installed in the current environment. Can also be used to check if git is installed.
func GitCheckout ¶
GitCheckout changes a local repository's HEAD.
func ReadFileToStr ¶
ReadFileToStr is a wrapper for os.ReadFile that checks for the file's existence before reading a file and returns the file's contents as a string.
func RunCommand ¶
RunCommand is a subset-wrapper for exec.Command, providing separate return values for stdout and stderr.
func RunCommandCombinedOutput ¶
RunCommandCombinedOutput is a subset-wrapper for exec.Command, returning both stdout and stderr in one string.
func RunCommandLiveOutput ¶ added in v0.0.2
func RunCommandLiveOutput(fStdout func(string), fStderr func(string), wd models.Path, command string, args ...string) error
RunCommandLiveOutput is a wrapper for exec.Command that takes a callback function for updates in both stdout and stderr streams.
func RunCommandLiveOutputCombinedOutput ¶ added in v0.0.2
func RunCommandLiveOutputCombinedOutput(fStdout func(string), wd models.Path, command string, args ...string) error
RunCommandLiveOutputCombinedOutput is a wrapper for exec.Command that takes a callback function for updates in a combined stdout and stderr stream.
func StringInsert ¶
func StringInsert(original string, insert string, startDelimiter string, endDelimiter string) (string, error)
StringInsert inserts a string between the start and end delimiter strings. Use StringInsertAtFirst if multiple occurrences of both delimiters are allowed in the input string.
func StringInsertAtFirst ¶
func StringInsertAtFirst(original string, insert string, startDelimiter string, endDelimiter string) (string, error)
StringInsertAtFirst is the same as StringInsert, but allows the occurrence of multiple delimiter string in the input string by only replacing the first start-end combination.
Types ¶
type FmtTreeConfig ¶
type FmtTreeConfig struct { /* Indent defines the indent contents for subnodes. */ Indent string /* NewLinesAtTopLevel defines if there should be any spacing between top-level nodes. */ NewLinesAtTopLevel bool }
FmtTreeConfig is a configuration structure when formatting a Node tree.