@@ -47,25 +47,24 @@ type Command struct {
4747//
4848// Example:
4949//
50- // env := map[string]string{"ENV": "VALUE"}
51- //
50+ // env := map[string]string{"ENV": "VALUE"}
5251type EnvVars map [string ]string
5352
5453// NewCommand creates a new command
5554// You can add option with variadic option argument
5655// Default timeout is set to 30 minutes
5756//
5857// Example:
59- // c := cmd.NewCommand("echo hello", function (c *Command) {
60- // c.WorkingDir = "/tmp"
61- // })
62- // c.Execute()
6358//
64- // or you can use existing options functions
59+ // c := cmd.NewCommand("echo hello", function (c *Command) {
60+ // c.WorkingDir = "/tmp"
61+ // })
62+ // c.Execute()
6563//
66- // c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
67- // c.Execute()
64+ // or you can use existing options functions
6865//
66+ // c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
67+ // c.Execute()
6968func NewCommand (cmd string , options ... func (* Command )) * Command {
7069 c := & Command {
7170 Command : cmd ,
@@ -90,12 +89,11 @@ func NewCommand(cmd string, options ...func(*Command)) *Command {
9089//
9190// Example:
9291//
93- // c := cmd.NewCommand(
94- // "echo hello",
95- // cmd.WithCustomBaseCommand(exec.Command("/bin/bash", "-c")),
96- // )
97- // c.Execute()
98- //
92+ // c := cmd.NewCommand(
93+ // "echo hello",
94+ // cmd.WithCustomBaseCommand(exec.Command("/bin/bash", "-c")),
95+ // )
96+ // c.Execute()
9997func WithCustomBaseCommand (baseCommand * exec.Cmd ) func (c * Command ) {
10098 return func (c * Command ) {
10199 baseCommand .Args = append (baseCommand .Args , c .Command )
@@ -108,9 +106,8 @@ func WithCustomBaseCommand(baseCommand *exec.Cmd) func(c *Command) {
108106//
109107// Example:
110108//
111- // c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
112- // c.Execute()
113- //
109+ // c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
110+ // c.Execute()
114111func WithStandardStreams (c * Command ) {
115112 c .StdoutWriter = io .MultiWriter (os .Stdout , & c .stdout , & c .combined )
116113 c .StderrWriter = io .MultiWriter (os .Stderr , & c .stderr , & c .combined )
@@ -135,8 +132,8 @@ func WithCustomStderr(writers ...io.Writer) func(c *Command) {
135132// WithTimeout sets the timeout of the command
136133//
137134// Example:
138- // cmd.NewCommand("sleep 10;", cmd.WithTimeout(500))
139135//
136+ // cmd.NewCommand("sleep 10;", cmd.WithTimeout(500))
140137func WithTimeout (t time.Duration ) func (c * Command ) {
141138 return func (c * Command ) {
142139 c .Timeout = t
@@ -201,13 +198,13 @@ func (c *Command) Combined() string {
201198 return c .combined .String ()
202199}
203200
204- //ExitCode returns the exit code of the command
201+ // ExitCode returns the exit code of the command
205202func (c * Command ) ExitCode () int {
206203 c .isExecuted ("ExitCode" )
207204 return c .exitCode
208205}
209206
210- //Executed returns if the command was already executed
207+ // Executed returns if the command was already executed
211208func (c * Command ) Executed () bool {
212209 return c .executed
213210}
0 commit comments