From 78ca8beb77cda7f2f668db3ff4544a6098d08525 Mon Sep 17 00:00:00 2001 From: Louis Ruch Date: Wed, 17 May 2023 22:39:55 -0700 Subject: [PATCH] fix(cli): Update storage CLI gen and help text --- .../cmd/commands/storagebucketscmd/funcs.go | 44 ++++--------------- .../storagebucketscmd/storagebuckets.gen.go | 15 +++++++ internal/cmd/gencli/input.go | 2 - 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/internal/cmd/commands/storagebucketscmd/funcs.go b/internal/cmd/commands/storagebucketscmd/funcs.go index 8ddbfd9973..48ee6c874e 100644 --- a/internal/cmd/commands/storagebucketscmd/funcs.go +++ b/internal/cmd/commands/storagebucketscmd/funcs.go @@ -14,9 +14,9 @@ import ( ) func init() { - extraFlagsFunc = extraPluginFlagsFuncImpl - extraActionsFlagsMapFunc = extraPluginActionsFlagsMapFuncImpl - extraFlagsHandlingFunc = extraPluginFlagHandlingFuncImpl + extraFlagsFunc = extraFlagsFuncImpl + extraActionsFlagsMapFunc = extraActionsFlagsMapFuncImpl + extraFlagsHandlingFunc = extraFlagHandlingFuncImpl } const ( @@ -31,7 +31,7 @@ type extraCmdVars struct { flagWorkerFilter string } -func extraPluginActionsFlagsMapFuncImpl() map[string][]string { +func extraActionsFlagsMapFuncImpl() map[string][]string { flags := map[string][]string{ "create": { bucketNameFlagName, @@ -45,7 +45,7 @@ func extraPluginActionsFlagsMapFuncImpl() map[string][]string { return flags } -func extraPluginFlagsFuncImpl(c *Command, set *base.FlagSets, _ *base.FlagSet) { +func extraFlagsFuncImpl(c *Command, set *base.FlagSets, _ *base.FlagSet) { f := set.NewFlagSet("Storage Bucket Options") for _, name := range flagsMap[c.Func] { @@ -73,7 +73,7 @@ func extraPluginFlagsFuncImpl(c *Command, set *base.FlagSets, _ *base.FlagSet) { } } -func extraPluginFlagHandlingFuncImpl(c *Command, f *base.FlagSets, opts *[]storagebuckets.Option) bool { +func extraFlagHandlingFuncImpl(c *Command, f *base.FlagSets, opts *[]storagebuckets.Option) bool { switch c.flagBucketName { case "": default: @@ -100,34 +100,6 @@ func extraPluginFlagHandlingFuncImpl(c *Command, f *base.FlagSets, opts *[]stora return true } -func (c *Command) extraPluginHelpFunc(helpMap map[string]func() string) string { - var helpStr string - switch c.Func { - case "create": - helpStr = base.WrapForHelpText([]string{ - "Usage: boundary storage-buckets create [options] [args]", - "", - " Create a storage bucket. Example:", - "", - ` $ boundary storage-buckets create -scope-id global -bucket-name test -name prodops -description "Storage bucket for ProdOps"`, - "", - "", - }) - - case "update": - helpStr = base.WrapForHelpText([]string{ - "Usage: boundary storage-buckets update [options] [args]", - "", - " Update a storage bucket given its ID. Example:", - "", - ` $ boundary storage-buckets update -id sb_1234567890 -name "devops" -description "Storage bucket for DevOps"`, - "", - "", - }) - } - return helpStr + c.Flags().Help() -} - func (c *Command) extraHelpFunc(helpMap map[string]func() string) string { var helpStr string switch c.Func { @@ -151,7 +123,7 @@ func (c *Command) extraHelpFunc(helpMap map[string]func() string) string { "", " Create a storage bucket:", "", - ` $ boundary storage-buckets create plugin -bucket-name prod_bucket`, + ` $ boundary storage-buckets create -plugin-name aws -bucket-name prod_bucket`, "", " Please see the subcommand help for detailed usage information.", }) @@ -163,7 +135,7 @@ func (c *Command) extraHelpFunc(helpMap map[string]func() string) string { "", " Update a storage bucket:", "", - ` $ boundary storage-buckets update plugin -id sb_1234567890 -name devops -description "For DevOps usage"`, + ` $ boundary storage-buckets update -id sb_1234567890 -name devops -description "For DevOps usage"`, "", " Please see the subcommand help for detailed usage information.", }) diff --git a/internal/cmd/commands/storagebucketscmd/storagebuckets.gen.go b/internal/cmd/commands/storagebucketscmd/storagebuckets.gen.go index 7ccf8f2cc1..42b0b3711a 100644 --- a/internal/cmd/commands/storagebucketscmd/storagebuckets.gen.go +++ b/internal/cmd/commands/storagebucketscmd/storagebuckets.gen.go @@ -70,6 +70,21 @@ func (c *Command) Help() string { switch c.Func { + case "create": + helpStr = helpMap[c.Func]() + c.Flags().Help() + + case "update": + helpStr = helpMap[c.Func]() + c.Flags().Help() + + case "read": + helpStr = helpMap[c.Func]() + c.Flags().Help() + + case "delete": + helpStr = helpMap[c.Func]() + c.Flags().Help() + + case "list": + helpStr = helpMap[c.Func]() + c.Flags().Help() + default: helpStr = c.extraHelpFunc(helpMap) diff --git a/internal/cmd/gencli/input.go b/internal/cmd/gencli/input.go index 8d6b813ecd..4ed04f5f10 100644 --- a/internal/cmd/gencli/input.go +++ b/internal/cmd/gencli/input.go @@ -582,7 +582,6 @@ var inputStructs = map[string][]*cmdInfo{ ResourceType: resource.StorageBucket.String(), Pkg: "storagebuckets", StdActions: []string{"create", "update", "read", "delete", "list"}, - SkipNormalHelp: true, HasExtraHelpFunc: true, HasExtraCommandVars: true, HasId: true, @@ -591,7 +590,6 @@ var inputStructs = map[string][]*cmdInfo{ Container: "Scope", IsPluginType: true, VersionedActions: []string{"update"}, - NeedsSubtypeInCreate: true, HasGenericAttributes: true, HasGenericSecrets: true, },