Documentation
¶
Index ¶
- Constants
- func CombineEnv(envs ...*[]string) []string
- func CombineEnvMaps(envs ...*map[string]string) map[string]string
- func EnvMapAsSlice(env map[string]string) []string
- func EnvSliceAsMap(env []string) map[string]string
- func GetCacheDir() (string, error)
- func GetOSShell(envShell *platform.PlatformMap[string]) string
- func GetOSShellArgs(cmd string) []string
- func GetRealPath(env []string, path string) string
- func GetShellWhich() string
- func IsGitURL(url string) bool
- func PathExists(path string) (bool, error)
- func ResolveEnvPaths(envs ...[]string) []string
- func RunCmdAsFile(env []string, contents string, envShell *platform.PlatformMap[string]) error
- func RunCmdGetOutput(env []string, bin string, args ...string) ([]byte, error)
- func RunCmdGetSuccess(env []string, bin string, args ...string) (bool, error)
- func RunCmdGetSuccessPassThrough(env []string, bin string, args ...string) (bool, error)
- func RunCmdPassThrough(env []string, bin string, args ...string) error
- func RunCmdPassThroughChained(env []string, commands [][]string) error
Constants ¶
const UNIX_DEFAULT_SHELL string = "bash"
UNIX_DEFAULT_SHELL is the default shell used on Unix-like systems if SHELL environment variable is not set.
Variables ¶
This section is empty.
Functions ¶
func CombineEnv ¶ added in v1.5.0
CombineEnv merges multiple slices of environment variable strings. Later slices will override earlier ones if keys conflict.
func CombineEnvMaps ¶ added in v1.5.0
CombineEnvMaps merges multiple maps of environment variables. Later maps will override earlier ones if keys conflict.
func EnvMapAsSlice ¶ added in v1.5.0
EnvMapAsSlice converts a map of environment variables to a slice of "KEY=VALUE" strings.
func EnvSliceAsMap ¶ added in v1.5.0
EnvSliceAsMap converts a slice of environment variable strings ("KEY=VALUE") to a map.
func GetCacheDir ¶ added in v1.8.0
GetCacheDir returns the path to the user's cache directory for the application. It creates the directory if it doesn't exist. The cache directory is typically located at `~/.config/.cache` on Linux/macOS and `%APPDATA%\.cache` on Windows.
func GetOSShell ¶ added in v1.1.0
func GetOSShell(envShell *platform.PlatformMap[string]) string
GetOSShell returns the appropriate shell for the current operating system. It considers the SHELL environment variable on Unix-like systems and allows overrides via envShell.
func GetOSShellArgs ¶ added in v1.1.0
GetOSShellArgs returns the appropriate shell arguments for executing a command string.
func GetRealPath ¶
GetRealPath resolves a path string, expanding environment variables and replacing "~" with the user's home directory. It takes a slice of environment variables to temporarily set during expansion.
func GetShellWhich ¶ added in v1.1.0
func GetShellWhich() string
GetShellWhich returns the command used to find the path of an executable (e.g., "which" or "where").
func IsGitURL ¶ added in v1.4.0
IsGitURL checks if a string is likely a Git URL. It checks for "https://" or "git@" prefixes.
func PathExists ¶ added in v1.4.0
PathExists checks if a file or directory exists at the given path. It returns true if the path exists, false otherwise. It does not distinguish between files and directories. An error is returned if os.Stat encounters an issue other than fs.ErrNotExist.
func ResolveEnvPaths ¶ added in v1.5.0
ResolveEnvPaths takes one or more slices of environment variable strings (e.g., "KEY=VALUE"), resolves any paths within the values using GetRealPath, and returns a single combined slice.
func RunCmdAsFile ¶ added in v1.2.0
RunCmdAsFile writes the given contents to a temporary shell script and executes it. This is useful for running multi-line commands or scripts.
func RunCmdGetOutput ¶
RunCmdGetOutput executes a command and returns its standard output.
func RunCmdGetSuccess ¶
RunCmdGetSuccess executes a command and returns true if it succeeds (exit code 0). Standard input, output, and error are not passed through.
func RunCmdGetSuccessPassThrough ¶ added in v1.9.4
RunCmdGetSuccessPassThrough executes a command, passes through streams, and returns true if it succeeds.
func RunCmdPassThrough ¶
RunCmdPassThrough executes a command and passes through its standard input, output, and error streams. It also resolves environment variable paths.
func RunCmdPassThroughChained ¶
RunCmdPassThroughChained executes a series of commands sequentially, passing through streams. If any command fails, the chain stops and an error is returned.
Types ¶
This section is empty.