Fix CLI help output and make more consistent (#605)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-10-09 20:26:48 -04:00
1 parent bd271b707d
commit 603b0582d7
23 files changed
+157 -162

No files matched your search

+14 -10
View File
@@ -32,10 +32,10 @@ type Command struct {
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create account resources within Boundary"
case "update":
return "Update account resources within Boundary"
case "set-password":
return "Directly set the password on an account resource"
case "change-password":
return "Change the password on an account resource"
default:
return common.SynopsisFunc(c.Func, "account")
}
@@ -98,6 +98,8 @@ func (c *Command) Help() string {
" Set the password on a password-type account:",
"",
` $ boundary accounts set-password -id apw_1234567890 -password <empty, to be read by stdin>`,
"",
"",
})
case "change-password":
helpStr = base.WrapForHelpText([]string{
@@ -108,6 +110,8 @@ func (c *Command) Help() string {
" Change the password on a password-type account:",
"",
` $ boundary accounts change-password -id apw_1234567890 -current-password <empty, to be read by stdin> -new-password <empty, to be read by stdin>`,
"",
"",
})
default:
helpStr = helpMap[c.Func]()
@@ -116,14 +120,14 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
if len(flagsMap[c.Func]) > 0 {
common.PopulateCommonFlags(c.Command, f, resource.Account.String(), flagsMap[c.Func])
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Account.String(), flagsMap[c.Func])
for _, name := range flagsMap[c.Func] {
switch name {
case "password":
+1 -2
View File
@@ -29,7 +29,7 @@ type PasswordCommand struct {
}
func (c *PasswordCommand) Synopsis() string {
return fmt.Sprintf("%s a password-type account within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a password-type account", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var passwordFlagsMap = map[string][]string{
@@ -67,7 +67,6 @@ func (c *PasswordCommand) Help() string {
func (c *PasswordCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
if len(passwordFlagsMap[c.Func]) > 0 {
@@ -44,12 +44,13 @@ func (c *PasswordCommand) Help() string {
" Invoke the password auth method to authenticate the Boundary CLI:",
"",
` $ boundary authenticate password -auth-method-id ampw_1234567890 -login-name foo -password "bar"`,
"",
"",
}) + c.Flags().Help()
}
func (c *PasswordCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
f.StringVar(&base.StringVar{
+14 -20
View File
@@ -24,14 +24,7 @@ type Command struct {
}
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create auth-method resources within Boundary"
case "update":
return "Update auth-method resources within Boundary"
default:
return common.SynopsisFunc(c.Func, "auth-method")
}
return common.SynopsisFunc(c.Func, "auth method")
}
var flagsMap = map[string][]string{
@@ -41,16 +34,16 @@ var flagsMap = map[string][]string{
}
func (c *Command) Help() string {
helpMap := common.HelpMap("auth-method")
helpMap := common.HelpMap("auth method")
var helpStr string
switch c.Func {
case "":
return base.WrapForHelpText([]string{
"Usage: boundary auth-methods [sub command] [options] [args]",
"",
" This command allows operations on Boundary auth-method resources. Example:",
" This command allows operations on Boundary auth method resources. Example:",
"",
" Read an auth-method:",
" Read an auth method:",
"",
` $ boundary auth-methods read -id ampw_1234567890`,
"",
@@ -60,9 +53,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary auth-methods create [type] [sub command] [options] [args]",
"",
" This command allows create operations on Boundary auth-method resources. Example:",
" This command allows create operations on Boundary auth method resources. Example:",
"",
" Create a password-type auth-method:",
" Create a password-type auth method:",
"",
` $ boundary auth-methods create password -name prodops -description "For ProdOps usage"`,
"",
@@ -72,9 +65,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary auth-methods update [type] [sub command] [options] [args]",
"",
" This command allows update operations on Boundary auth-method resources. Example:",
" This command allows update operations on Boundary auth method resources. Example:",
"",
" Update a password-type auth-method:",
" Update a password-type auth method:",
"",
` $ boundary auth-methods update password -id ampw_1234567890 -name devops -description "For DevOps usage"`,
"",
@@ -87,13 +80,14 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.AuthMethod.String(), flagsMap[c.Func])
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.AuthMethod.String(), flagsMap[c.Func])
return set
}
@@ -27,7 +27,7 @@ type PasswordCommand struct {
}
func (c *PasswordCommand) Synopsis() string {
return fmt.Sprintf("%s a password-type auth-method within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a password type auth-method", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var passwordFlagsMap = map[string][]string{
@@ -42,7 +42,7 @@ func (c *PasswordCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary auth-methods create password [options] [args]",
"",
" Create a password-type auth-method. Example:",
" Create a password-type auth method. Example:",
"",
` $ boundary auth-methods create password -name prodops -description "Password auth-method for ProdOps"`,
"",
@@ -53,7 +53,7 @@ func (c *PasswordCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary auth-methods update password [options] [args]",
"",
" Update a password-type auth-method given its ID. Example:",
" Update a password-type auth method given its ID. Example:",
"",
` $ boundary auth-methods update password -id ampw_1234567890 -name "devops" -description "Password auth-method for DevOps"`,
"",
@@ -66,12 +66,10 @@ func (c *PasswordCommand) Help() string {
func (c *PasswordCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(passwordFlagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "password-type auth-method", passwordFlagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "password-type auth method", passwordFlagsMap[c.Func])
f := set.NewFlagSet("Password Auth-Method Options")
f = set.NewFlagSet("Password Auth-Method Options")
addPasswordFlags(c, f)
return set
@@ -25,7 +25,7 @@ type Command struct {
}
func (c *Command) Synopsis() string {
return common.SynopsisFunc(c.Func, "auth-token")
return common.SynopsisFunc(c.Func, "auth token")
}
var flagsMap = map[string][]string{
@@ -35,7 +35,7 @@ var flagsMap = map[string][]string{
}
func (c *Command) Help() string {
helpMap := common.HelpMap("auth-token")
helpMap := common.HelpMap("auth token")
if c.Func == "" {
return helpMap["base"]()
}
+7 -1
View File
@@ -22,7 +22,7 @@ func memberSynopsisFunc(inFunc string) string {
case strings.HasPrefix(inFunc, "remove"):
in = "Remove users from"
}
return wordwrap.WrapString(fmt.Sprintf("%s a group within Boundary", in), base.TermWidth)
return wordwrap.WrapString(fmt.Sprintf("%s a group", in), base.TermWidth)
}
func addMembersHelp() string {
@@ -32,6 +32,8 @@ func addMembersHelp() string {
` Adds members (users) to a group given its ID. The "user" flag can be specified multiple times. Example:`,
"",
` $ boundary groups add-members -id g_1234567890 -user u_1234567890`,
"",
"",
})
}
@@ -42,6 +44,8 @@ func setMembersHelp() string {
` Sets the complete set of members (users) on a group given its ID. The "user" flag can be specified multiple times. Example:`,
"",
` $ boundary groups set-principals -id g_1234567890 -user u_anon -user u_1234567890`,
"",
"",
})
}
@@ -52,6 +56,8 @@ func removeMembersHelp() string {
` Removes members (users) from a group given its ID. The "user" flag can be specified multiple times. Example:`,
"",
` $ boundary groups remove-members -id g_1234567890 -user u_1234567890`,
"",
"",
})
}
+4 -8
View File
@@ -26,12 +26,11 @@ type Command struct {
func (c *Command) Synopsis() string {
switch c.Func {
case "", "create", "update", "read", "delete", "list":
return common.SynopsisFunc(c.Func, "group")
case "add-members", "set-members", "remove-members":
return memberSynopsisFunc(c.Func)
default:
return common.SynopsisFunc(c.Func, "group")
}
return ""
}
var helpMap = func() map[string]func() string {
@@ -63,11 +62,8 @@ func (c *Command) Help() string {
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
return set
}
@@ -24,14 +24,7 @@ type Command struct {
}
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create host-catalog resources within Boundary"
case "update":
return "Update host-catalog resources within Boundary"
default:
return common.SynopsisFunc(c.Func, "host-catalog")
}
return common.SynopsisFunc(c.Func, "host catalog")
}
var flagsMap = map[string][]string{
@@ -41,16 +34,16 @@ var flagsMap = map[string][]string{
}
func (c *Command) Help() string {
helpMap := common.HelpMap("host-catalog")
helpMap := common.HelpMap("host catalog")
var helpStr string
switch c.Func {
case "":
return base.WrapForHelpText([]string{
"Usage: boundary host-catalogs [sub command] [options] [args]",
"",
" This command allows operations on Boundary host-catalog resources. Example:",
" This command allows operations on Boundary host catalog resources. Example:",
"",
" Read a host-catalog:",
" Read a host catalog:",
"",
` $ boundary host-catalogs read -id hcst_1234567890`,
"",
@@ -60,9 +53,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-catalogs create [type] [sub command] [options] [args]",
"",
" This command allows create operations on Boundary host-catalog resources. Example:",
" This command allows create operations on Boundary host catalog resources. Example:",
"",
" Create a static-type host-catalog:",
" Create a static-type host catalog:",
"",
` $ boundary host-catalogs create static -name prodops -description "For ProdOps usage"`,
"",
@@ -72,9 +65,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-catalogs update [type] [sub command] [options] [args]",
"",
" This command allows update operations on Boundary host-catalog resources. Example:",
" This command allows update operations on Boundary host catalog resources. Example:",
"",
" Update a static-type host-catalog:",
" Update a static-type host catalog:",
"",
` $ boundary host-catalogs update static -id hcst_1234567890 -name devops -description "For DevOps usage"`,
"",
@@ -87,12 +80,14 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.HostCatalog.String(), flagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.HostCatalog.String(), flagsMap[c.Func])
return set
}
+5 -8
View File
@@ -23,7 +23,7 @@ type StaticCommand struct {
}
func (c *StaticCommand) Synopsis() string {
return fmt.Sprintf("%s a static-type host-catalog within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a static-type host catalog", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var staticFlagsMap = map[string][]string{
@@ -38,7 +38,7 @@ func (c *StaticCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary host-catalogs create static [options] [args]",
"",
" Create a static-type host-catalog. Example:",
" Create a static-type host catalog. Example:",
"",
` $ boundary host-catalogs create static -name prodops -description "Static host-catalog for ProdOps"`,
"",
@@ -49,7 +49,7 @@ func (c *StaticCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary host-catalogs update static [options] [args]",
"",
" Update a static-type host-catalog given its ID. Example:",
" Update a static-type host catalog given its ID. Example:",
"",
` $ boundary host-catalogs update static -id hcst_1234567890 -name "devops" -description "Static host-catalog for DevOps"`,
"",
@@ -61,11 +61,8 @@ func (c *StaticCommand) Help() string {
func (c *StaticCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(staticFlagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "static-type host-catalog", staticFlagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "static-type host catalog", staticFlagsMap[c.Func])
return set
}
+5 -9
View File
@@ -24,14 +24,7 @@ type Command struct {
}
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create host resources within Boundary"
case "update":
return "Update host resources within Boundary"
default:
return common.SynopsisFunc(c.Func, "host")
}
return common.SynopsisFunc(c.Func, "host")
}
var flagsMap = map[string][]string{
@@ -87,8 +80,11 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Host.String(), flagsMap[c.Func])
+2 -6
View File
@@ -25,7 +25,7 @@ type StaticCommand struct {
}
func (c *StaticCommand) Synopsis() string {
return fmt.Sprintf("%s a static-type host within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a static-type host", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var staticFlagsMap = map[string][]string{
@@ -63,12 +63,8 @@ func (c *StaticCommand) Help() string {
func (c *StaticCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
if len(staticFlagsMap[c.Func]) > 0 {
common.PopulateCommonFlags(c.Command, f, "static-type host", staticFlagsMap[c.Func])
}
common.PopulateCommonFlags(c.Command, f, "static-type host", staticFlagsMap[c.Func])
f = set.NewFlagSet("Static Host Options")
+21 -22
View File
@@ -27,18 +27,14 @@ type Command struct {
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create host-set resources within Boundary"
case "update":
return "Update host-set resources within Boundary"
case "add-hosts":
return "Add hosts to the specified host-set"
return "Add hosts to the specified host set"
case "remove-hosts":
return "Remove hosts from the specified host-set"
return "Remove hosts from the specified host set"
case "set-hosts":
return "Set the full contents of the hosts on the specified host-set"
return "Set the full contents of the hosts on the specified host set"
default:
return common.SynopsisFunc(c.Func, "host-set")
return common.SynopsisFunc(c.Func, "host set")
}
}
@@ -52,16 +48,16 @@ var flagsMap = map[string][]string{
}
func (c *Command) Help() string {
helpMap := common.HelpMap("host-set")
helpMap := common.HelpMap("host set")
var helpStr string
switch c.Func {
case "":
return base.WrapForHelpText([]string{
"Usage: boundary host-sets [sub command] [options] [args]",
"",
" This command allows operations on Boundary host-set resources. Example:",
" This command allows operations on Boundary host set resources. Example:",
"",
" Read a host-set:",
" Read a host set:",
"",
` $ boundary host-sets read -id hsst_1234567890`,
"",
@@ -71,9 +67,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-sets create [type] [sub command] [options] [args]",
"",
" This command allows create operations on Boundary host-set resources. Example:",
" This command allows create operations on Boundary host set resources. Example:",
"",
" Create a static-type host-set:",
" Create a static-type host set:",
"",
` $ boundary host-sets create static -name prodops -description "For ProdOps usage"`,
"",
@@ -83,9 +79,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-sets update [type] [sub command] [options] [args]",
"",
" This command allows update operations on Boundary host-set resources. Example:",
" This command allows update operations on Boundary host set resources. Example:",
"",
" Update a static-type host-set:",
" Update a static-type host set:",
"",
` $ boundary host-sets update static -id hsst_1234567890 -name devops -description "For DevOps usage"`,
"",
@@ -95,9 +91,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-sets add-hosts [sub command] [options] [args]",
"",
" This command allows adding hosts to host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
" This command allows adding hosts to host set resources, if the types match and the operation is allowed by the given host set type. Example:",
"",
" Add static-type hosts to a static-type host-set:",
" Add static-type hosts to a static-type host set:",
"",
` $ boundary host-sets add-hosts -id hsst_1234567890 -host hst_1234567890 -host hst_0987654321`,
})
@@ -105,9 +101,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-sets remove-hosts [sub command] [options] [args]",
"",
" This command allows removing hosts from host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
" This command allows removing hosts from host set resources, if the types match and the operation is allowed by the given host set type. Example:",
"",
" Remove static-type hosts from a static-type host-set:",
" Remove static-type hosts from a static-type host set:",
"",
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_0987654321`,
})
@@ -115,9 +111,9 @@ func (c *Command) Help() string {
helpStr = base.WrapForHelpText([]string{
"Usage: boundary host-sets set-hosts [sub command] [options] [args]",
"",
" This command allows setting the complete set of hosts on host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
" This command allows setting the complete set of hosts on host set resources, if the types match and the operation is allowed by the given host set type. Example:",
"",
" Set the complete set of static-type hosts on a static-type host-set:",
" Set the complete set of static-type hosts on a static-type host set:",
"",
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_1234567890`,
})
@@ -128,8 +124,11 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.HostSet.String(), flagsMap[c.Func])
+4 -5
View File
@@ -23,7 +23,7 @@ type StaticCommand struct {
}
func (c *StaticCommand) Synopsis() string {
return fmt.Sprintf("%s a static-type host-set within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a static-type host set", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var staticFlagsMap = map[string][]string{
@@ -38,7 +38,7 @@ func (c *StaticCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary host-sets create static [options] [args]",
"",
" Create a static-type host-set. Example:",
" Create a static-type host set. Example:",
"",
` $ boundary host-sets create static -name prodops -description "Static host-set for ProdOps"`,
"",
@@ -49,7 +49,7 @@ func (c *StaticCommand) Help() string {
info = base.WrapForHelpText([]string{
"Usage: boundary host-sets update static [options] [args]",
"",
" Update a static-type host-set given its ID. Example:",
" Update a static-type host set given its ID. Example:",
"",
` $ boundary host-sets update static -id hsst_1234567890 -name "devops" -description "Static host-set for DevOps"`,
"",
@@ -61,9 +61,8 @@ func (c *StaticCommand) Help() string {
func (c *StaticCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "static-type host-set", staticFlagsMap[c.Func])
common.PopulateCommonFlags(c.Command, f, "static-type host set", staticFlagsMap[c.Func])
return set
}
+1 -1
View File
@@ -26,7 +26,7 @@ func principalsGrantsSynopsisFunc(inFunc string, principals bool) string {
case strings.HasPrefix(inFunc, "remove"):
in = fmt.Sprintf("Remove %s from", switchStr)
}
return wordwrap.WrapString(fmt.Sprintf("%s a role within Boundary", in), base.TermWidth)
return wordwrap.WrapString(fmt.Sprintf("%s a role", in), base.TermWidth)
}
func addPrincipalsHelp() string {
+2 -4
View File
@@ -75,11 +75,9 @@ func (c *Command) Help() string {
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
}
return set
}
+13 -15
View File
@@ -48,22 +48,20 @@ func (c *Command) Help() string {
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Scope.String(), flagsMap[c.Func])
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Scope.String(), flagsMap[c.Func])
if c.Func == "create" {
f.BoolVar(&base.BoolVar{
Name: "skip-admin-role-creation",
Target: &c.flagSkipAdminRoleCreation,
Usage: "If set, a role granting the current user access to administer the newly-created scope will not automatically be created",
})
f.BoolVar(&base.BoolVar{
Name: "skip-default-role-creation",
Target: &c.flagSkipDefaultRoleCreation,
Usage: "If set, a role granting the anonymous user access to log into auth methods and a few other actions within the newly-created scope will not automatically be created",
})
}
if c.Func == "create" {
f.BoolVar(&base.BoolVar{
Name: "skip-admin-role-creation",
Target: &c.flagSkipAdminRoleCreation,
Usage: "If set, a role granting the current user access to administer the newly-created scope will not automatically be created",
})
f.BoolVar(&base.BoolVar{
Name: "skip-default-role-creation",
Target: &c.flagSkipDefaultRoleCreation,
Usage: "If set, a role granting the anonymous user access to log into auth methods and a few other actions within the newly-created scope will not automatically be created",
})
}
return set
+2 -5
View File
@@ -67,11 +67,8 @@ func (c *Command) Help() string {
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Session.String(), flagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Session.String(), flagsMap[c.Func])
return set
}
+16
View File
@@ -1,13 +1,29 @@
package targets
import (
"fmt"
"strings"
"time"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/api/targets"
"github.com/hashicorp/boundary/internal/cmd/base"
"github.com/mitchellh/go-wordwrap"
)
func hostSetSynopsisFunc(inFunc string) string {
var in string
switch {
case strings.HasPrefix(inFunc, "add"):
in = "Add host sets to"
case strings.HasPrefix(inFunc, "set"):
in = "Set the full contents of the host sets on"
case strings.HasPrefix(inFunc, "remove"):
in = "Remove host sets from"
}
return wordwrap.WrapString(fmt.Sprintf("%s a target", in), base.TermWidth)
}
func generateTargetTableOutput(in *targets.Target) string {
nonAttributeMap := map[string]interface{}{
"ID": in.Id,
+16 -5
View File
@@ -29,10 +29,10 @@ type Command struct {
func (c *Command) Synopsis() string {
switch c.Func {
case "create":
return "Create target resources within Boundary"
case "update":
return "Update target resources within Boundary"
case "add-host-sets", "set-host-sets", "remove-host-sets":
return hostSetSynopsisFunc(c.Func)
case "authorize-session":
return "Request session authorization against the target"
default:
return common.SynopsisFunc(c.Func, "target")
}
@@ -97,6 +97,8 @@ func (c *Command) Help() string {
" Add host-set resources to a tcp-type target:",
"",
` $ boundary targets add-host-sets -id ttcp_1234567890 -host-set hsst_1234567890 -host-set hsst_0987654321`,
"",
"",
})
case "remove-host-sets":
helpStr = base.WrapForHelpText([]string{
@@ -107,6 +109,8 @@ func (c *Command) Help() string {
" Remove host-set resources from a tcp-type target:",
"",
` $ boundary targets add-host-sets -id ttcp_1234567890 -host hsst_1234567890 -host-set hsst_0987654321`,
"",
"",
})
case "set-host-sets":
helpStr = base.WrapForHelpText([]string{
@@ -117,6 +121,8 @@ func (c *Command) Help() string {
" Set host-set resources on a tcp-type target:",
"",
` $ boundary targets set-host-sets -id ttcp_1234567890 -host-set hsst_1234567890`,
"",
"",
})
case "authorize-session":
helpStr = base.WrapForHelpText([]string{
@@ -127,6 +133,8 @@ func (c *Command) Help() string {
" Set host-set resources on a tcp-type target:",
"",
` $ boundary targets authorize-session -id ttcp_1234567890`,
"",
"",
})
default:
helpStr = helpMap[c.Func]()
@@ -135,8 +143,11 @@ func (c *Command) Help() string {
}
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) == 0 {
return c.FlagSet(base.FlagSetNone)
}
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, resource.Target.String(), flagsMap[c.Func])
+1 -2
View File
@@ -28,7 +28,7 @@ type TcpCommand struct {
}
func (c *TcpCommand) Synopsis() string {
return fmt.Sprintf("%s a tcp-type target within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
return fmt.Sprintf("%s a tcp-type target", textproto.CanonicalMIMEHeaderKey(c.Func))
}
var tcpFlagsMap = map[string][]string{
@@ -66,7 +66,6 @@ func (c *TcpCommand) Help() string {
func (c *TcpCommand) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
f := set.NewFlagSet("Command Options")
common.PopulateCommonFlags(c.Command, f, "tcp-type target", tcpFlagsMap[c.Func])
+4 -8
View File
@@ -26,12 +26,11 @@ type Command struct {
func (c *Command) Synopsis() string {
switch c.Func {
case "", "create", "update", "read", "delete", "list":
return common.SynopsisFunc(c.Func, "user")
case "add-accounts", "set-accounts", "remove-accounts":
return accountSynopsisFunc(c.Func)
default:
return common.SynopsisFunc(c.Func, "user")
}
return ""
}
var helpMap = func() map[string]func() string {
@@ -63,11 +62,8 @@ func (c *Command) Help() string {
func (c *Command) Flags() *base.FlagSets {
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
if len(flagsMap[c.Func]) > 0 {
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
}
f := set.NewFlagSet("Command Options")
populateFlags(c, f, flagsMap[c.Func])
return set
}
+1 -1
View File
@@ -21,7 +21,7 @@ func SynopsisFunc(inFunc, resType string) string {
default:
articleType = fmt.Sprintf("a %s", articleType)
}
return wordwrap.WrapString(fmt.Sprintf("%s %s within Boundary", textproto.CanonicalMIMEHeaderKey(inFunc), articleType), base.TermWidth)
return wordwrap.WrapString(fmt.Sprintf("%s %s", textproto.CanonicalMIMEHeaderKey(inFunc), articleType), base.TermWidth)
}
func HelpMap(resType string) map[string]func() string {