@@ -30,7 +30,7 @@ import (
30
30
"github.com/sirupsen/logrus"
31
31
)
32
32
33
- // A generic command abstraction
33
+ // A generic command abstraction.
34
34
type Command struct {
35
35
cmds []* command
36
36
stdErrWriters , stdOutWriters []io.Writer
@@ -39,7 +39,7 @@ type Command struct {
39
39
filter * filter
40
40
}
41
41
42
- // The internal command representation
42
+ // The internal command representation.
43
43
type command struct {
44
44
* exec.Cmd
45
45
pipeWriter * io.PipeWriter
@@ -51,19 +51,19 @@ type filter struct {
51
51
replaceAll string
52
52
}
53
53
54
- // A generic command exit status
54
+ // A generic command exit status.
55
55
type Status struct {
56
56
waitStatus syscall.WaitStatus
57
57
* Stream
58
58
}
59
59
60
- // Stream combines standard output and error
60
+ // Stream combines standard output and error.
61
61
type Stream struct { //nolint: errname
62
62
stdOut string
63
63
stdErr string
64
64
}
65
65
66
- // Commands is an abstraction over multiple Command structures
66
+ // Commands is an abstraction over multiple Command structures.
67
67
type Commands []* Command
68
68
69
69
// New creates a new command from the provided arguments.
@@ -91,7 +91,7 @@ func cmdWithDir(dir, cmd string, args ...string) *exec.Cmd {
91
91
return c
92
92
}
93
93
94
- // Pipe creates a new command where the previous should be piped to
94
+ // Pipe creates a new command where the previous should be piped to.
95
95
func (c * Command ) Pipe (cmd string , args ... string ) * Command {
96
96
pipeCmd := cmdWithDir (c .cmds [0 ].Dir , cmd , args ... )
97
97
@@ -121,7 +121,7 @@ func (c *Command) Verbose() *Command {
121
121
}
122
122
123
123
// isVerbose returns true if the command is in verbose mode, either set locally
124
- // or global
124
+ // or global.
125
125
func (c * Command ) isVerbose () bool {
126
126
return GetGlobalVerbose () || c .verbose
127
127
}
@@ -174,7 +174,7 @@ func (c *Command) Filter(regex, replaceAll string) (*Command, error) {
174
174
175
175
// Run starts the command and waits for it to finish. It returns an error if
176
176
// the command execution was not possible at all, otherwise the Status.
177
- // This method prints the commands output during execution
177
+ // This method prints the commands output during execution.
178
178
func (c * Command ) Run () (res * Status , err error ) {
179
179
return c .run (true )
180
180
}
@@ -199,7 +199,7 @@ func (c *Command) RunSuccess() error {
199
199
return err
200
200
}
201
201
202
- // String returns a string representation of the full command
202
+ // String returns a string representation of the full command.
203
203
func (c * Command ) String () string {
204
204
str := []string {}
205
205
for _ , x := range c .cmds {
@@ -246,7 +246,7 @@ func (c *Command) RunSilentSuccess() error {
246
246
return err
247
247
}
248
248
249
- // run is the internal run method
249
+ // run is the internal run method.
250
250
func (c * Command ) run (printOutput bool ) (res * Status , err error ) {
251
251
var runErr error
252
252
stdOutBuffer := & bytes.Buffer {}
@@ -371,17 +371,17 @@ func (c *Command) run(printOutput bool) (res *Status, err error) {
371
371
return status , runErr
372
372
}
373
373
374
- // Success returns if a Status was successful
374
+ // Success returns if a Status was successful.
375
375
func (s * Status ) Success () bool {
376
376
return s .waitStatus .ExitStatus () == 0
377
377
}
378
378
379
- // ExitCode returns the exit status of the command status
379
+ // ExitCode returns the exit status of the command status.
380
380
func (s * Status ) ExitCode () int {
381
381
return s .waitStatus .ExitStatus ()
382
382
}
383
383
384
- // Output returns stdout of the command status
384
+ // Output returns stdout of the command status.
385
385
func (s * Stream ) Output () string {
386
386
return s .stdOut
387
387
}
@@ -392,7 +392,7 @@ func (s *Stream) OutputTrimNL() string {
392
392
return strings .TrimSpace (s .stdOut )
393
393
}
394
394
395
- // Error returns the stderr of the command status
395
+ // Error returns the stderr of the command status.
396
396
func (s * Stream ) Error () string {
397
397
return s .stdErr
398
398
}
0 commit comments