Documentation
¶
Index ¶
- func DotSlash(path string) string
- func EnsureNewline(b []byte) []byte
- func Executable() (string, error)
- func FindCueMod(path string) (root string, err error)
- func FindRootLeaf(target string) (root string, leaf string, err error)
- func MakeCopyFunc(ctx context.Context, efs embed.FS, dest string) fs.WalkDirFunc
- func MakeWalkFunc(a *txtar.Archive) fs.WalkDirFunc
- func Remove(ctx context.Context, path string)
- func RunInteractiveCmd(ctx context.Context, name string, args ...string) error
- type RunResult
- func RunCmd(ctx context.Context, name string, args ...string) (result RunResult, err error)
- func RunCmdA(ctx context.Context, w io.Writer, name string, args ...string) (result RunResult, err error)
- func RunCmdFunc(ctx context.Context, w io.Writer, name string, args []string, ...) (result RunResult, err error)
- func RunCmdW(ctx context.Context, w io.Writer, name string, args ...string) (result RunResult, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DotSlash ¶ added in v0.100.0
DotSlash ensures a relative path has a leading ./ needed for CUE loading.
func EnsureNewline ¶
EnsureNewline adds a trailing newline if not already there.
func Executable ¶ added in v0.104.2
Executable returns the fully qualified path to the "holos" executable by searching through the PATH. If the current executable starts with "holos", it returns that path, otherwise it searches for "holos" in PATH.
func FindCueMod ¶ added in v0.98.0
FindCueMod returns the root module location containing the cue.mod.
func FindRootLeaf ¶ added in v0.98.0
FindRootLeaf returns the root path containing the cue.mod and the leaf path relative to the root for the given target path. FindRootLeaf calls filepath.Clean on the returned paths.
func MakeCopyFunc ¶ added in v0.104.2
MakeCopyFunc returns a fs.WalkDirFunc copying from embed.FS efs to dest. Useful for embedded test case fixtures.
func MakeWalkFunc ¶
func MakeWalkFunc(a *txtar.Archive) fs.WalkDirFunc
Types ¶
type RunResult ¶
runResult holds the stdout and stderr of a command.
func RunCmd ¶
RunCmd runs a command within a context, captures its output, provides debug logging, and returns the result. Example:
result, err := RunCmd(ctx, "echo", "hello")
if err != nil {
return wrapper.Wrap(err)
}
fmt.Println(result.Stdout.String())
Output:
"hello\n"
func RunCmdA ¶ added in v0.101.0
func RunCmdA(ctx context.Context, w io.Writer, name string, args ...string) (result RunResult, err error)
RunCmdA calls RunCmd and always copies the result stderr to w.
func RunCmdFunc ¶ added in v0.104.2
func RunCmdFunc(ctx context.Context, w io.Writer, name string, args []string, preRun func(*exec.Cmd) error) (result RunResult, err error)
RunCmdFunc runs a command within a context, captures its output, provides debug logging, and returns the result. preRun is called after configuration and before exec.Cmd.Run.
RunCmdFunc copies stderr to w when an error occurs. The copy is safe for concurrent use with other functions in this package.