exec

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Overview

Package exec provides a wrapper around the os/exec package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd(config Config, command string, args ...string) (string, string, error)

Cmd executes a given command with given config.

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

func GetCmdMutation(cmdKey string) (string, bool)

GetCmdMutation returns the cmdLocation for a given cmdKey and whether that key exists

func GetFinalExecutablePath

func GetFinalExecutablePath() (string, error)

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

func IsPowerShell(shellName string) bool

IsPowerShell returns whether a shell name is PowerShell

func LaunchURL

func LaunchURL(url string) error

LaunchURL opens a URL in the default browser.

func MutateCommand

func MutateCommand(cmd string, shellPref ShellPreference) string

MutateCommand performs some basic string mutations to make commands more useful.

func RegisterCmdMutation

func RegisterCmdMutation(cmdKey string, cmdLocation string) error

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

Jump to

Keyboard shortcuts

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