Documentation ¶
Overview ¶
Package env contains runtime environment variables for usql, along with various helper funcs to determine the user's configuration.
Index ¶
- func Chdir(u *user.User, path string) error
- func Dequote(s string, quote byte) (string, error)
- func EditFile(u *user.User, path, line, s string) ([]rune, error)
- func Exec(s string) (string, error)
- func Get(name string) string
- func Getenv(keys ...string) (string, bool)
- func Getshell() (string, string)
- func Getvar(s string, v Vars) (bool, string, error)
- func GoTime() string
- func HistoryFile(u *user.User) string
- func Listing(w io.Writer)
- func OpenFile(u *user.User, path string, relative bool) (string, *os.File, error)
- func ParseBool(value, name string) (string, error)
- func ParseKeywordBool(value, name string, keywords ...string) (string, error)
- func Pget(name string) (string, error)
- func Pipe(c string) (io.WriteCloser, *exec.Cmd, error)
- func Pset(name, value string) (string, error)
- func Ptoggle(name, extra string) (string, error)
- func Pwrite(w io.Writer) error
- func RCFile(u *user.User) string
- func Set(name, value string) error
- func Shell(s string) error
- func Unquote(u *user.User, exec bool, v Vars) func(string, bool) (bool, string, error)
- func Unset(name string) error
- func ValidIdentifier(n string) error
- type Vars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chdir ¶ added in v0.5.0
Chdir changes the current working directory to the specified path, or to the user's home directory if path is not specified.
func Exec ¶ added in v0.5.0
Exec executes s using the user's SHELL / COMSPEC with -c (or /c) and returning the captured output. See Getshell.
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 Getenv ¶ added in v0.6.0
Getenv tries retrieving successive keys from os environment variables.
func Getshell ¶ added in v0.8.2
Getshell returns the user's defined SHELL, or system default (if found on path) and the appropriate command-line argument for the returned shell.
Looks at the SHELL environment variable first, and then COMSPEC/ComSpec on Windows. Defaults to sh on non-Windows systems, and to cmd.exe on Windows.
func GoTime ¶ added in v0.9.1
func GoTime() string
GoTime returns the user's time format converted to Go's time.Format value.
func HistoryFile ¶
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 Listing ¶ added in v0.13.3
Listing writes the formatted variables listing to w, separated into different sections for all known variables.
func OpenFile ¶ added in v0.5.0
OpenFile opens a file for read (os.O_RDONLY), returning the full, expanded path of the file. Callers are responsible for closing the returned file.
func ParseKeywordBool ¶ added in v0.9.0
func RCFile ¶
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 Shell ¶ added in v0.8.2
Shell runs s as a shell. When s is empty the user's SHELL or COMSPEC is used. See Getshell.
func Unquote ¶ added in v0.5.0
Unquote returns a func that unquotes strings for the user.
When exec is true, backtick'd strings will be executed using the provided user's shell (see Exec).
func ValidIdentifier ¶ added in v0.5.0
ValidIdentifier returns an error when n is not a valid identifier.