Skip to content

Commit acafbbf

Browse files
feat: tabular output for ps (#73)
1 parent 5fb7024 commit acafbbf

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

cmd/schedctl/ps.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package cmd
22

33
import (
4+
"fmt"
5+
"os"
6+
"text/tabwriter"
7+
48
"github.com/spf13/cobra"
59

610
"schedctl/internal/constants"
711
"schedctl/internal/containerd"
812
"schedctl/internal/containers"
9-
"schedctl/internal/output"
1013
"schedctl/internal/podman"
1114
)
1215

@@ -49,9 +52,14 @@ func ps(cmd *cobra.Command, _ []string) error {
4952
containersList = append(containersList, podmanList...)
5053
}
5154

55+
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
56+
fmt.Fprintln(w, "PID\tID\tNAME")
57+
5258
for _, container := range containersList {
53-
_, _ = output.Out("pid: %d, id: %s, name: %s", container.PID, container.ID, container.Name)
59+
fmt.Fprintf(w, "%d\t%s\t%s\n", container.PID, container.ID, container.Name)
5460
}
5561

62+
w.Flush()
63+
5664
return nil
5765
}

0 commit comments

Comments
 (0)