forked from gojek/proctor
-
Notifications
You must be signed in to change notification settings - Fork 3
/
list.go
32 lines (27 loc) · 940 Bytes
/
list.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
package list
import (
"fmt"
"github.com/fatih/color"
"github.com/gojektech/proctor/daemon"
"github.com/gojektech/proctor/io"
"github.com/spf13/cobra"
)
func NewCmd(printer io.Printer, proctorDClient daemon.Client) *cobra.Command {
return &cobra.Command{
Use: "list",
Short: "List scheduled jobs",
Long: "This command helps to list scheduled jobs",
Example: fmt.Sprintf("proctor schedule list"),
Run: func(cmd *cobra.Command, args []string) {
scheduledProcs, err := proctorDClient.ListScheduledProcs()
if err != nil {
printer.Println(err.Error(), color.FgRed)
return
}
printer.Println(fmt.Sprintf("%-40s %-30s %-20s %s", "ID", "PROC NAME", "GROUP NAME", "TAGS"), color.FgGreen)
for _, scheduledProc := range scheduledProcs {
printer.Println(fmt.Sprintf("%-40s %-30s %-20s %s", scheduledProc.ID, scheduledProc.Name, scheduledProc.Group,scheduledProc.Tags), color.Reset)
}
},
}
}