From 1b183bc3b9d5b11eb08e6c5c7520179b4b0072ce Mon Sep 17 00:00:00 2001 From: REDDY PRASAD Date: Sat, 28 Sep 2019 21:42:21 +0530 Subject: [PATCH 1/2] Fix template not used for help command --- cmd/porter/main.go | 11 +++++++---- cmd/porter/{helptext => templates}/usage.txt | 0 2 files changed, 7 insertions(+), 4 deletions(-) rename cmd/porter/{helptext => templates}/usage.txt (100%) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index c3d99b32d..370a268f8 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -1,3 +1,5 @@ +//go:generate packr2 + package main import ( @@ -58,9 +60,10 @@ func buildRootCommand() *cobra.Command { cmd.AddCommand(alias) } - help := newHelptextBox() - usage, _ := help.FindString("usage.txt") + tmplBox := newTemplateBox() + usage, _ := tmplBox.FindString("usage.txt") cmd.SetUsageTemplate(usage) + cobra.AddTemplateFunc("ShouldShowGroupCommands", ShouldShowGroupCommands) cobra.AddTemplateFunc("ShouldShowGroupCommand", ShouldShowGroupCommand) cobra.AddTemplateFunc("ShouldShowUngroupedCommands", ShouldShowUngroupedCommands) @@ -73,8 +76,8 @@ func buildRootCommand() *cobra.Command { return cmd } -func newHelptextBox() *packr.Box { - return packr.New("github.com/deislabs/porter/cmd/porter/helptext", "./helptext") +func newTemplateBox() *packr.Box { + return packr.New("github.com/deislabs/porter/cmd/porter/templates", "./templates") } func ShouldShowGroupCommands(cmd *cobra.Command, group string) bool { diff --git a/cmd/porter/helptext/usage.txt b/cmd/porter/templates/usage.txt similarity index 100% rename from cmd/porter/helptext/usage.txt rename to cmd/porter/templates/usage.txt From e00adda82dd2a1acfbfa7946e0b5726edc535da9 Mon Sep 17 00:00:00 2001 From: REDDY PRASAD Date: Mon, 30 Sep 2019 21:06:52 +0530 Subject: [PATCH 2/2] Revert refactored logic --- cmd/porter/{templates => helptext}/usage.txt | 0 cmd/porter/main.go | 9 ++++----- 2 files changed, 4 insertions(+), 5 deletions(-) rename cmd/porter/{templates => helptext}/usage.txt (100%) diff --git a/cmd/porter/templates/usage.txt b/cmd/porter/helptext/usage.txt similarity index 100% rename from cmd/porter/templates/usage.txt rename to cmd/porter/helptext/usage.txt diff --git a/cmd/porter/main.go b/cmd/porter/main.go index 370a268f8..a149191fd 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -60,10 +60,9 @@ func buildRootCommand() *cobra.Command { cmd.AddCommand(alias) } - tmplBox := newTemplateBox() - usage, _ := tmplBox.FindString("usage.txt") + help := newHelptextBox() + usage, _ := help.FindString("usage.txt") cmd.SetUsageTemplate(usage) - cobra.AddTemplateFunc("ShouldShowGroupCommands", ShouldShowGroupCommands) cobra.AddTemplateFunc("ShouldShowGroupCommand", ShouldShowGroupCommand) cobra.AddTemplateFunc("ShouldShowUngroupedCommands", ShouldShowUngroupedCommands) @@ -76,8 +75,8 @@ func buildRootCommand() *cobra.Command { return cmd } -func newTemplateBox() *packr.Box { - return packr.New("github.com/deislabs/porter/cmd/porter/templates", "./templates") +func newHelptextBox() *packr.Box { + return packr.New("github.com/deislabs/porter/cmd/porter/helptext", "./helptext") } func ShouldShowGroupCommands(cmd *cobra.Command, group string) bool {