From a76f55403b022e78416d27129f7a6de64324978d Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Wed, 22 Mar 2017 13:26:18 +0800 Subject: [PATCH] Use TabWriter to keep output of "kubectl get xx -w" aligned. Use TabWriter to keep output of "kubectl get xx -w" aligned. --- pkg/kubectl/cmd/get.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/kubectl/cmd/get.go b/pkg/kubectl/cmd/get.go index dd8a306aa1f..38e65cc63bf 100644 --- a/pkg/kubectl/cmd/get.go +++ b/pkg/kubectl/cmd/get.go @@ -245,16 +245,19 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [ // print the current object if !isWatchOnly { var objsToPrint []runtime.Object + writer := printers.GetNewTabWriter(out) + if isList { objsToPrint, _ = meta.ExtractList(obj) } else { objsToPrint = append(objsToPrint, obj) } for _, objToPrint := range objsToPrint { - if err := printer.PrintObj(objToPrint, out); err != nil { + if err := printer.PrintObj(objToPrint, writer); err != nil { return fmt.Errorf("unable to output the provided object: %v", err) } } + writer.Flush() } // print watched changes