shellhook

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 7 Imported by: 0

README

go-shellhook

shell hook library for go programs inspired by direnv

usage

get the latest version

go get -u github.com/patrickhuber/go-shellhook

For a full example see the example

note

This library executes in the shell prompt and does an export of variables in the current shell session. These shell variables will persist between commands.

Documentation

Index

Constants

View Source
const (
	Bash = "bash"
)
View Source
const (
	Powershell = "powershell"
)

Variables

View Source
var ErrNotExist = fs.ErrNotExist

Functions

func Export added in v0.2.0

func Export(e Exporter, vars map[string]string) string

func Hook

func Hook(shell Shell, metadata *Metadata) (string, error)

func Unset added in v0.2.0

func Unset(u Unsetter, keys []string) string

Types

type Exporter added in v0.1.4

type Exporter interface {
	Export(key string, value string) string
}

type Hooker added in v0.1.4

type Hooker interface {
	Hook() (string, error)
}

type Metadata

type Metadata struct {
	// the path to the executable
	Executable string

	// the name of the hook
	Name string

	// the args to pass
	Args []string
}

type Namer added in v0.1.4

type Namer interface {
	Name() string
}

type Shell

type Shell interface {
	Namer
	Exporter
	Hooker
	Unsetter
}

func New added in v0.2.1

func New(shell string) (Shell, error)

func NewBash

func NewBash() Shell

func NewPowershell

func NewPowershell() Shell

type Unsetter added in v0.1.6

type Unsetter interface {
	Unset(key string) string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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