From 0bfd83ec00f74695a3cde0ffcaf018a64f178a2f Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Sat, 2 Jan 2016 10:27:36 +0200 Subject: [PATCH] Add --dont-prettify option to user info commands --- pkg/cmd/list.go | 10 +++++++++- pkg/cmd/root.go | 1 + pkg/cmd/version.go | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index cba7cf8..06a176a 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -71,6 +71,14 @@ var List = &cli.Command{ data = append(data, tmpl.Info().String()) } - tabular.Print([]string{"Tag", "Repository", "Created"}, data) + shouldntPrettify := GetBoolFlag(c, "dont-prettify") + if shouldntPrettify { + for _, name := range names { + fmt.Print(name, " ") + } + fmt.Println() + } else { + tabular.Print([]string{"Tag", "Repository", "Created"}, data) + } }, } diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 8b32894..ee2cb4a 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -47,6 +47,7 @@ func Run() { Root.AddCommand(Template) + Version.PersistentFlags().BoolP("dont-prettify", "", false, "Only print the version without fancy formatting") Root.AddCommand(Version) Root.Execute() diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 862218f..df06182 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -14,9 +14,14 @@ import ( var Version = &cli.Command{ Use: "version", Short: "Show the boilr version information", - Run: func(_ *cli.Command, args []string) { + Run: func(c *cli.Command, args []string) { MustValidateArgs(args, []validate.Argument{}) - tlog.Info(fmt.Sprint("Current version is ", boilr.Version)) + shouldntPrettify := GetBoolFlag(c, "dont-prettify") + if shouldntPrettify { + fmt.Println(boilr.Version) + } else { + tlog.Info(fmt.Sprint("Current version is ", boilr.Version)) + } }, } -- GitLab