forked from bjatkin/puffin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
110 lines (78 loc) · 2.91 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package puffin
import (
"io"
"os"
"syscall"
)
// Cmd is the interface for a command runner
type Cmd interface {
// CombinedOutput runs the command and returns its
// combined standard output and standard error.
CombinedOutput() ([]byte, error)
// Environ returns a copy of the environment in which
// the command would be run as it is currently configured.
Environ() []string
// Output runs the command and returns its standard output.
Output() ([]byte, error)
// Run starts the specified command and waits for it to complete.
Run() error
// Start starts the specified command but does not wait for it to complete.
Start() error
// StderrPipe returns a pipe that will be connected to the command's
// standard error when the command starts.
StderrPipe() (io.ReadCloser, error)
// StdinPipe returns a pipe that will be connected to the command's
// standard input when the command starts.
StdinPipe() (io.WriteCloser, error)
// StdoutPipe returns a pipe that will be connected to the command's
// standard output when the command starts.
StdoutPipe() (io.ReadCloser, error)
// String returns a human-readable description of Cmd
String() string
// Wait waits for the command to exit and waits for any
// copying to stdin, stdout, or stderr to complete.
Wait() error
// Path returns the path of the command to run.
Path() string
// SetPath sets the path of the command to run.
SetPath(string)
// Args returns the command line arguments, including the command as Args[0]
Args() []string
// SetArgs sets the command line arguments
SetArgs([]string)
// Env returns the environment of the process
Env() []string
// SetEnv sets the environment of the process
SetEnv([]string)
// Dir returns the working directory of the command
Dir() string
// SetDir sets the working dir of the command
SetDir(string)
// Stdin returns the command's standard input
Stdin() io.Reader
// SetStdin sets the command's standard input
SetStdin(io.Reader)
// Stdout returns the command's standard output
Stdout() io.Writer
// SetStdout sets the command's standard output
SetStdout(io.Writer)
// Stderr returns the command's standard error
Stderr() io.Writer
// SetStderr sets the command's standard error
SetStderr(io.Writer)
// ExtraFiles returns additional open files to be inherited by the new process
ExtraFiles() []*os.File
// SetExtraFiles set additional open files to be inherited by the new process
SetExtraFiles([]*os.File)
// SysProcAttr returns optional, operating system-specific attributes
SysProcAttr() *syscall.SysProcAttr
// SetSysProcAttr sets the SysProcAttr field on the underlying command
SetSysProcAttr(*syscall.SysProcAttr)
// Process is the underlying process, once started.
Process() *os.Process
// ProcessState contains information about an exited process,
// available after a call to Wait or Run.
ProcessState() *os.ProcessState
// Err contains a LookPath error, if any
Err() error
}