env

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2017 License: MIT Imports: 15 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.5.0

func All() map[string]string

All returns all variables.

func Chdir added in v0.5.0

func Chdir(u *user.User, path string) error

Chdir changes the current working directory to the specified path, or to the user's home directory if path is not specified.

func EditFile

func EditFile(u *user.User, path, line, s string) ([]rune, error)

EditFile edits a file. If path is empty, then a temporary file will be created.

func Exec added in v0.5.0

func Exec(s string) (string, error)

Exec runs s using the user's SHELL / COMSPEC (Windows, aka 'ComSpec'), with -c (or /c).

When SHELL or COMSPEC is not defined, then "sh" / "cmd.exe" will be used instead, assuming it is found on the system's PATH.

func Getvar added in v0.5.0

func Getvar(s string) (bool, string, error)

Getvar retrieves a variable.

func HistoryFile

func HistoryFile(u *user.User) string

HistoryFile returns the path to the history file.

Defaults to ~/.<command name>_history, overridden by environment variable <COMMAND NAME>_HISTORY (ie, ~/.usql_history and USQL_HISTORY).

func OpenFile added in v0.5.0

func OpenFile(u *user.User, path string, relative bool) (string, *os.File, error)

OpenFile opens a file for reading, returning the full, expanded path of the file. All callers are responsible for closing the returned file.

func PassFile added in v0.5.0

func PassFile(u *user.User) string

PassFile returns the path to the password file.

Defaults to ~/.<command name>pass, overridden by environment variable <COMMAND NAME>PASS (ie, ~/.usqlpass and USQLPASS).

func PassFileEntry added in v0.5.0

func PassFileEntry(u *user.User, v *dburl.URL) (*url.Userinfo, error)

PassFileEntry determines if there is a password file entry for a specific database URL.

func RCFile

func RCFile(u *user.User) string

RCFile returns the path to the RC file.

Defaults to ~/.<command name>rc, overridden by environment variable <COMMAND NAME>RC (ie, ~/.usqlrc and USQLRC).

func Set added in v0.5.0

func Set(name, value string) error

Set sets a variable.

func Unquote added in v0.5.0

func Unquote(u *user.User, s string, exec bool) (string, error)

Unquote unquotes the string.

func Unset added in v0.5.0

func Unset(name string) error

Unset unsets a variable.

func ValidIdentifier added in v0.5.0

func ValidIdentifier(n string) error

ValidIdentifier returns an error when n is not a valid identifier.

Types

type Pvars added in v0.5.0

type Pvars interface{}

Pvars is a map

type Vars added in v0.5.0

type Vars map[string]string

Vars is a map of variables.

func (Vars) All added in v0.5.0

func (v Vars) All() map[string]string

All returns all variables as a map.

func (Vars) Set added in v0.5.0

func (v Vars) Set(name, value string)

Set sets a variable name.

func (Vars) Unset added in v0.5.0

func (v Vars) Unset(name string)

Unset unsets a variable name.

Jump to

Keyboard shortcuts

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