cli(workers): Add extra help func
This commit is contained in:
1 parent
cca044d8cb
commit
80752e9a24
5 files changed
+29
-1
No files matched your search
@@ -1030,6 +1030,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"workers": func() (cli.Command, error) {
|
||||
return &workerscmd.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
},
|
||||
"workers create": func() (cli.Command, error) {
|
||||
return &workerscmd.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
|
||||
@@ -9,6 +9,27 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
)
|
||||
|
||||
func (c *Command) extraHelpFunc(helpMap map[string]func() string) string {
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
"Usage: boundary workers [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows operations on Boundary worker resources. Example:",
|
||||
"",
|
||||
" Read a worker:",
|
||||
"",
|
||||
` $ boundary workers read -id w_1234567890`,
|
||||
"",
|
||||
" Please see the workers subcommand help for detailed usage information.",
|
||||
})
|
||||
default:
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) printListTable(items []*workers.Worker) string {
|
||||
if len(items) == 0 {
|
||||
return "No workers found"
|
||||
|
||||
@@ -79,7 +79,7 @@ func (c *Command) Help() string {
|
||||
|
||||
default:
|
||||
|
||||
helpStr = helpMap["base"]()
|
||||
helpStr = c.extraHelpFunc(helpMap)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func HelpMap(resType string) map[string]func() string {
|
||||
resource.Host.String(): "h",
|
||||
resource.Session.String(): "s",
|
||||
resource.Target.String(): "t",
|
||||
resource.Worker.String(): "w",
|
||||
}
|
||||
return map[string]func() string{
|
||||
"base": func() string {
|
||||
|
||||
@@ -458,6 +458,7 @@ var inputStructs = map[string][]*cmdInfo{
|
||||
ResourceType: resource.Worker.String(),
|
||||
Pkg: "workers",
|
||||
StdActions: []string{"read", "update", "delete", "list"},
|
||||
HasExtraHelpFunc: true,
|
||||
HasId: true,
|
||||
Container: "Scope",
|
||||
HasName: true,
|
||||
|
||||
Reference in new issue
Block a user