Documentation ¶
Overview ¶
Package shellx helps to write shell-like Go code.
Index ¶
- Constants
- Variables
- func CopyFile(source, dest string, perms fs.FileMode) error
- func Output(logger model.Logger, command string, args ...string) ([]byte, error)
- func OutputCommandLine(logger model.Logger, cmdline string) ([]byte, error)
- func OutputCommandLineQuiet(cmdline string) ([]byte, error)
- func OutputEx(config *Config, argv *Argv, envp *Envp) ([]byte, error)
- func OutputQuiet(command string, args ...string) ([]byte, error)
- func Run(logger model.Logger, command string, args ...string) error
- func RunCommandLine(logger model.Logger, cmdline string) error
- func RunCommandLineQuiet(cmdline string) error
- func RunEx(config *Config, argv *Argv, envp *Envp) error
- func RunQuiet(command string, args ...string) error
- type Argv
- type Config
- type Dependencies
- type Envp
- type StdlibDependencies
Constants ¶
const ( // FlagShowStdoutStderr enables connecting the child's stdout and stderr // to the current program's stdout and stderr. FlagShowStdoutStderr = 1 << iota )
Variables ¶
var ErrNoCommandToExecute = errors.New("shellx: no command to execute")
ErrNoCommandToExecute means that the command line is empty.
Functions ¶
func Output ¶
Output is like OutputQuiet except that it logs the command to be executed and the environment variables specific to this command.
func OutputCommandLine ¶
OutputCommandLine is like OutputCommandLineQuiet but logs the command to execute as well as the command-specific environment variables.
func OutputCommandLineQuiet ¶
OutputCommandLineQuiet is like OutputQuiet but takes a command line as argument.
func OutputEx ¶
OutputEx implements Output and OutputQuiet.
func OutputQuiet ¶
OutputQuiet is like RunQuiet except that, in case of success, it captures the standard output and returns it to the caller.
func Run ¶
Run is like RunQuiet except that it also logs the command to exec, the environment variables specific to this command, the text logged to stdout and stderr.
func RunCommandLine ¶
RunCommandLine is like RunCommandLineQuiet but logs the command to execute as well as the command-specific environment variables.
func RunCommandLineQuiet ¶
RunCommandLineQuiet is like RunQuiet but takes a command line as argument.
Types ¶
type Argv ¶
type Argv struct { // P is the MANDATORY program to execute. P string // V contains the OPTIONAL arguments. V []string }
Argv contains the complete argv.
func ParseCommandLine ¶
ParseCommandLine creates an instance of Argv from the given command line.
type Config ¶
type Config struct { // Logger is the OPTIONAL logger to use. Logger model.Logger // Flags contains OPTIONAL binary flags to configure the program. Flags int64 }
Config contains config for executing programs.
type Dependencies ¶
type Dependencies interface { // CmdOutput is equivalent to calling c.Output. CmdOutput(c *execabs.Cmd) ([]byte, error) // CmdRun is equivalent to calling c.Run. CmdRun(c *execabs.Cmd) error // LookPath is equivalent to calling execabs.LookPath. LookPath(file string) (string, error) }
Dependencies is the library on which this package depends.
var Library Dependencies = &StdlibDependencies{}
Library contains the default dependencies.
type Envp ¶
type Envp struct { // V contains the OPTIONAL environment variables to add to the current // environment when we're executing commands. V []string }
Envp is the environment in which we execute commands.
type StdlibDependencies ¶
type StdlibDependencies struct{}
StdlibDependencies contains the stdlib implementation of the Dependencies.
func (*StdlibDependencies) CmdOutput ¶
func (*StdlibDependencies) CmdOutput(c *execabs.Cmd) ([]byte, error)
CmdOutput implements Dependencies.
func (*StdlibDependencies) CmdRun ¶
func (*StdlibDependencies) CmdRun(c *execabs.Cmd) error
CmdRun implements Dependencies.
func (*StdlibDependencies) LookPath ¶
func (*StdlibDependencies) LookPath(file string) (string, error)
LookPath implements Dependencies.
Directories ¶
Path | Synopsis |
---|---|
Package shellxtesting supports shellx testing.
|
Package shellxtesting supports shellx testing. |