From 48eb7a082dfcca6b16a3466a98cd27b04deb07c7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Mar 2018 16:09:52 +0200 Subject: [PATCH] Fix docker version output alignment Use tabwriter to print the version output Signed-off-by: Sebastiaan van Stijn --- cli/command/system/version.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/command/system/version.go b/cli/command/system/version.go index 20995dc38a..a0214d882b 100644 --- a/cli/command/system/version.go +++ b/cli/command/system/version.go @@ -4,6 +4,7 @@ import ( "fmt" "runtime" "sort" + "text/tabwriter" "text/template" "time" @@ -195,11 +196,12 @@ func runVersion(dockerCli command.Cli, opts *versionOptions) error { }) } } - - if err2 := tmpl.Execute(dockerCli.Out(), vd); err2 != nil && err == nil { + t := tabwriter.NewWriter(dockerCli.Out(), 15, 1, 1, ' ', 0) + if err2 := tmpl.Execute(t, vd); err2 != nil && err == nil { err = err2 } - dockerCli.Out().Write([]byte{'\n'}) + t.Write([]byte("\n")) + t.Flush() return err }