Skip to content

Commit e8525bc

Browse files
committed
removed pipe executor
1 parent e22103e commit e8525bc

File tree

3 files changed

+3
-93
lines changed

3 files changed

+3
-93
lines changed

cmd/park.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ Think of it as a remote stash command.
2828
}
2929

3030
func init() {
31-
RootCmd.AddCommand(parkCmd)
31+
//RootCmd.AddCommand(parkCmd)
3232
}

executor/executor.go

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -44,75 +44,4 @@ func ExecuteCommand(command string, argv ...string) (string, error) {
4444
}
4545

4646
return stdOutBuffer.String(), nil
47-
}
48-
49-
func ExecutePipe(outBuf *bytes.Buffer, callStack ...*exec.Cmd) (err error) {
50-
51-
var errBuf bytes.Buffer
52-
53-
pipeStack := make([]*io.PipeWriter, len(callStack)-1)
54-
55-
i := 0
56-
for ; i < len(pipeStack)-1; i++ {
57-
inp, out := io.Pipe()
58-
callStack[i].Stdout = out
59-
callStack[i].Stderr = &errBuf
60-
callStack[i+1].Stdin = inp
61-
pipeStack[i] = out
62-
}
63-
64-
callStack[i].Stdout = outBuf
65-
callStack[i].Stderr = &errBuf
66-
67-
if err := call(callStack, pipeStack); err != nil {
68-
return err
69-
}
70-
return nil
71-
}
72-
73-
func call(stack []*exec.Cmd, pipes []*io.PipeWriter) (err error) {
74-
if stack[0].Process == nil {
75-
fmt.Println("jkhjkhjkhjkhjkhkhjk")
76-
if err = stack[0].Start(); err != nil {
77-
return err
78-
}
79-
}
80-
if len(stack) >= 1 {
81-
if err = stack[1].Start(); err != nil {
82-
return err
83-
}
84-
defer func() {
85-
if err == nil {
86-
fmt.Println("JKSHDJKASHDJKSAHD" + strconv.Itoa(len(pipes)))
87-
88-
pipes[0].Close()
89-
90-
err = call(stack[1:], pipes[1:])
91-
}
92-
}()
93-
}
94-
return stack[0].Wait()
95-
}
96-
97-
func sd() {
98-
99-
c1 := exec.Command("ls", "-lah")
100-
c2 := exec.Command("wc", "-l")
101-
102-
r, w := io.Pipe()
103-
104-
c1.Stdout = w
105-
c2.Stdin = r
106-
107-
var b2 bytes.Buffer
108-
109-
c2.Stdout = &b2
110-
111-
c1.Start()
112-
c2.Start()
113-
c1.Wait()
114-
w.Close()
115-
c2.Wait()
116-
117-
io.Copy(os.Stdout, &b2)
118-
}
47+
}

executor/executor_test.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,4 @@ func TestRunCommand(t *testing.T) {
2626
So(err, ShouldNotBeNil)
2727
})
2828
})
29-
}
30-
31-
func TestExecutePipe(t *testing.T) {
32-
Convey("Running tests on 'ExecutePipe', function ", t, func() {
33-
Convey("piping commands should not return error", func() {
34-
35-
var output bytes.Buffer
36-
37-
err := ExecutePipe(&output,
38-
exec.Command("ls", "-lah"),
39-
exec.Command("grep","."),
40-
exec.Command("sort", "-r"),
41-
)
42-
43-
io.Copy(os.Stdout, &output)
44-
45-
t.Log(err)
46-
})
47-
})
48-
}
29+
}

0 commit comments

Comments
 (0)