From 04e56be23b25fd3c54e52c67d399a791daaa4bd9 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Sat, 28 May 2016 16:08:09 +0300 Subject: [PATCH] Refactor template list --dont-prettify flag logic --- pkg/cmd/list.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 06a176a..780b687 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "sort" + "strings" cli "github.com/spf13/cobra" @@ -39,7 +40,7 @@ func ListTemplates() (map[string]bool, error) { var List = &cli.Command{ Use: "list ", Short: "List project templates found in the local template registry", - Run: func(c *cli.Command, args []string) { + Run: func(cmd *cli.Command, args []string) { MustValidateArgs(args, []validate.Argument{}) MustValidateTemplateDir() @@ -71,12 +72,8 @@ var List = &cli.Command{ data = append(data, tmpl.Info().String()) } - shouldntPrettify := GetBoolFlag(c, "dont-prettify") - if shouldntPrettify { - for _, name := range names { - fmt.Print(name, " ") - } - fmt.Println() + if GetBoolFlag(cmd, "dont-prettify") { + fmt.Println(strings.Join(names, " ")) } else { tabular.Print([]string{"Tag", "Repository", "Created"}, data) } -- GitLab