exec

package
v0.32.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

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(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 CmdWithPrint

func CmdWithPrint(command string, args ...string) error

CmdWithPrint executes a given command with given config and prints the command.

func GetOSShell added in v0.25.1

func GetOSShell(shellPref Shell) (string, []string)

GetOSShell returns the shell and shellArgs based on the current OS

func IsPowershell added in v0.26.0

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.

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.

func PrintCfg

func PrintCfg() Config

PrintCfg is a helper function for returning a Config struct with Print set to true.

type Shell added in v0.32.6

type Shell 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 */
}

Shell 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