diff --git a/internal/cmd/commands/scopescmd/funcs.go b/internal/cmd/commands/scopescmd/funcs.go index 66655a0dfa..2f65fc3a73 100644 --- a/internal/cmd/commands/scopescmd/funcs.go +++ b/internal/cmd/commands/scopescmd/funcs.go @@ -75,6 +75,15 @@ func extraFlagsFuncImpl(c *Command, set *base.FlagSets, f *base.FlagSet) { } func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]scopes.Option) bool { + // Validate inputs + switch c.Func { + case "attach-storage-policy": + if len(c.flagStoragePolicyId) == 0 { + c.UI.Error("No storage policy ID supplied via -storage-policy-id") + return false + } + } + if c.flagSkipAdminRoleCreation { *opts = append(*opts, scopes.WithSkipAdminRoleCreation(c.flagSkipAdminRoleCreation)) } @@ -234,3 +243,34 @@ func printItemTable(item *scopes.Scope, resp *api.Response) string { return base.WrapForHelpText(ret) } + +func (c *Command) extraHelpFunc(_ map[string]func() string) string { + var helpStr string + switch c.Func { + case "attach-storage-policy": + helpStr = base.WrapForHelpText([]string{ + "Usage: boundary scopes attach-storage-policy [options] [args]", + "", + " This command allows attaching a storage policy to scope resources. Example:", + "", + " Attach storage policy to a scope:", + "", + ` $ boundary scopes attach-storage-policy -id o_1234567890 -storage-policy-id pst_1234567890`, + "", + "", + }) + case "detach-storage-policy": + helpStr = base.WrapForHelpText([]string{ + "Usage: boundary scope detach-storage-policy [options] [args]", + "", + " This command allows detaching a storage policy from scope resources. Example:", + "", + " Detach storage policy from scope:", + "", + ` $ boundary scopes detach-storage-policy -id o_1234567890`, + "", + "", + }) + } + return helpStr + c.Flags().Help() +} diff --git a/internal/cmd/commands/scopescmd/scopes.gen.go b/internal/cmd/commands/scopescmd/scopes.gen.go index 1e1089360b..3e40d61407 100644 --- a/internal/cmd/commands/scopescmd/scopes.gen.go +++ b/internal/cmd/commands/scopescmd/scopes.gen.go @@ -87,7 +87,7 @@ func (c *Command) Help() string { default: - helpStr = helpMap["base"]() + helpStr = c.extraHelpFunc(helpMap) } diff --git a/internal/cmd/gencli/input.go b/internal/cmd/gencli/input.go index cb8d1d09e0..b8e797171e 100644 --- a/internal/cmd/gencli/input.go +++ b/internal/cmd/gencli/input.go @@ -576,6 +576,7 @@ var inputStructs = map[string][]*cmdInfo{ Pkg: "scopes", StdActions: []string{"create", "read", "update", "delete", "list"}, HasExtraCommandVars: true, + HasExtraHelpFunc: true, HasId: true, Container: "Scope", HasName: true,