Documentation ¶
Overview ¶
Package exec provides a wrapper around the os/exec package
Index ¶
- func Cmd(config Config, command string, args ...string) (string, string, error)
- func CmdWithContext(ctx context.Context, config Config, command string, args ...string) (string, string, error)
- func GetCmdMutation(cmdKey string) (string, bool)
- func GetFinalExecutablePath() (string, error)
- func GetOSShell(shellPref ShellPreference) (string, []string)
- func IsPowerShell(shellName string) bool
- func LaunchURL(url string) error
- func MutateCommand(cmd string, shellPref ShellPreference) string
- func RegisterCmdMutation(cmdKey string, cmdLocation string) error
- type Config
- type ShellPreference
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CmdWithContext ¶
func CmdWithContext(ctx context.Context, config Config, command string, args ...string) (string, string, error)
CmdWithContext executes a given command with given config.
func GetCmdMutation ¶
GetCmdMutation returns the cmdLocation for a given cmdKey and whether that key exists
func GetFinalExecutablePath ¶
GetFinalExecutablePath returns the absolute path to the current executable, following any symlinks along the way.
func GetOSShell ¶
func GetOSShell(shellPref ShellPreference) (string, []string)
GetOSShell returns the shell and shellArgs based on the current OS
func IsPowerShell ¶
IsPowerShell returns whether a shell name is PowerShell
func MutateCommand ¶
func MutateCommand(cmd string, shellPref ShellPreference) string
MutateCommand performs some basic string mutations to make commands more useful.
func RegisterCmdMutation ¶
RegisterCmdMutation registers local ./ commands that should change to the specified cmdLocation
Types ¶
type Config ¶
type Config struct { Print bool Dir string Env []string CommandPrinter func(format string, a ...any) Stdout io.Writer Stderr io.Writer }
Config is a struct for configuring the Cmd function.
type ShellPreference ¶
type ShellPreference struct { Windows string `` /* 290-byte string literal not displayed */ Linux string `` /* 185-byte string literal not displayed */ Darwin string `` /* 186-byte string literal not displayed */ }
ShellPreference represents the desired shell to use for a given command