execute

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package execute is a simple package that wraps the os/exec Command features for convenient use in asdf. It was inspired by https://github.com/chen-keinan/go-command-eval

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentEnv added in v0.16.5

func CurrentEnv() map[string]string

CurrentEnv returns the current environment as a map

func MapToSlice

func MapToSlice(env map[string]string) (slice []string)

MapToSlice converts an env map to env slice suitable for syscall.Exec

func MergeEnv added in v0.16.5

func MergeEnv(map1, map2 map[string]string) map[string]string

MergeEnv takes two maps with string keys and values and merges them.

func MergeWithCurrentEnv added in v0.16.5

func MergeWithCurrentEnv(env map[string]string) (slice []string)

MergeWithCurrentEnv merges the provided map into the current environment variables

func SliceToMap added in v0.16.5

func SliceToMap(env []string) map[string]string

SliceToMap converts an env map to env slice suitable for syscall.Exec

Types

type Command

type Command struct {
	Command    string
	Expression string
	Args       []string
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
	Env        map[string]string
}

Command represents a Bash command that can be executed by asdf

func New

func New(command string, args []string) Command

New takes a string containing the path to a Bash script, and a slice of string arguments and returns a Command struct

func NewExpression

func NewExpression(expression string, args []string) Command

NewExpression takes a string containing a Bash expression and a slice of string arguments and returns a Command struct

func (Command) Run

func (c Command) Run() error

Run executes a Command with Bash and returns the error if there is one

Jump to

Keyboard shortcuts

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