Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved cmdOperators handling from RunCmd to StartCmd #259

Merged
merged 2 commits into from
Mar 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions icmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ func Command(command string, args ...string) Cmd {

// RunCmd runs a command and returns a Result
func RunCmd(cmd Cmd, cmdOperators ...CmdOp) *Result {
for _, op := range cmdOperators {
op(&cmd)
}
result := StartCmd(cmd)
result := StartCmd(cmd, cmdOperators...)
if result.Error != nil {
return result
}
Expand All @@ -223,7 +220,10 @@ func RunCommand(command string, args ...string) *Result {
}

// StartCmd starts a command, but doesn't wait for it to finish
func StartCmd(cmd Cmd) *Result {
func StartCmd(cmd Cmd, cmdOperators ...CmdOp) *Result {
for _, op := range cmdOperators {
op(&cmd)
}
result := buildCmd(cmd)
if result.Error != nil {
return result
Expand Down