fix(cli): Update storage CLI gen and help text

pull/3251/head
Louis Ruch 3 years ago committed by Timothy Messier
parent a783c91b2d
commit 78ca8beb77
No known key found for this signature in database
GPG Key ID: EFD2F184F7600572

@ -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.",
})

@ -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)

@ -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,
},

Loading…
Cancel
Save