forked from pachyderm/pachyderm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pretty.go
43 lines (37 loc) · 1 KB
/
pretty.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
package pretty
import (
"fmt"
"io"
ppsclient "github.com/pachyderm/pachyderm/src/client/pps"
)
func PrintJobHeader(w io.Writer) {
fmt.Fprint(w, "ID\tOUTPUT\tSTATE\t\n")
}
func PrintJobInfo(w io.Writer, jobInfo *ppsclient.JobInfo) {
fmt.Fprintf(w, "%s\t", jobInfo.Job.ID)
if jobInfo.OutputCommit != nil {
fmt.Fprintf(w, "%s/%s\t", jobInfo.OutputCommit.Repo.Name, jobInfo.OutputCommit.ID)
} else {
fmt.Fprintf(w, "-\t")
}
fmt.Fprintf(w, "%s\t\n", jobInfo.State.String())
}
func PrintPipelineHeader(w io.Writer) {
fmt.Fprint(w, "NAME\tINPUT\tOUTPUT\t\n")
}
func PrintPipelineInfo(w io.Writer, pipelineInfo *ppsclient.PipelineInfo) {
fmt.Fprintf(w, "%s\t", pipelineInfo.Pipeline.Name)
for i, input := range pipelineInfo.Inputs {
fmt.Fprintf(w, "%s", input.Repo.Name)
if i == len(pipelineInfo.Inputs)-1 {
fmt.Fprintf(w, "\t")
} else {
fmt.Fprintf(w, ", ")
}
}
if pipelineInfo.OutputRepo != nil {
fmt.Fprintf(w, "%s\t\n", pipelineInfo.OutputRepo.Name)
} else {
fmt.Fprintf(w, "\t\n")
}
}