diff --git a/pkg/cmd/create/create_secret.go b/pkg/cmd/create/create_secret.go index cfd932024..b9bb191f9 100644 --- a/pkg/cmd/create/create_secret.go +++ b/pkg/cmd/create/create_secret.go @@ -44,10 +44,11 @@ import ( // This is the entry point of create_secret.go which will be called by create.go func NewCmdCreateSecret(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command { cmd := &cobra.Command{ - Use: "secret", - Short: i18n.T("Create a secret using specified subcommand"), - Long: i18n.T("Create a secret using specified subcommand."), - Run: cmdutil.DefaultSubCommandRun(ioStreams.ErrOut), + Use: "secret (docker-registry | generic | tls)", + DisableFlagsInUseLine: true, + Short: i18n.T("Create a secret using a specified subcommand"), + Long: secretLong, + Run: cmdutil.DefaultSubCommandRun(ioStreams.ErrOut), } cmd.AddCommand(NewCmdCreateSecretDockerRegistry(f, ioStreams)) cmd.AddCommand(NewCmdCreateSecretTLS(f, ioStreams)) @@ -58,6 +59,15 @@ func NewCmdCreateSecret(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) var ( secretLong = templates.LongDesc(i18n.T(` + Create a secret with specified type. + + A docker-registry type secret is for accessing a container registry. + + A generic type secret indicate an Opaque secret type. + + A tls type secret holds TLS certificate and its associated key.`)) + + secretForGenericLong = templates.LongDesc(i18n.T(` Create a secret based on a file, directory, or specified literal value. A single secret may package one or more key/value pairs. @@ -70,7 +80,7 @@ var ( packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).`)) - secretExample = templates.Examples(i18n.T(` + secretForGenericExample = templates.Examples(i18n.T(` # Create a new secret named my-secret with keys for each file in folder bar kubectl create secret generic my-secret --from-file=path/to/bar @@ -134,8 +144,8 @@ func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericiooptions.IOS Use: "generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run=server|client|none]", DisableFlagsInUseLine: true, Short: i18n.T("Create a secret from a local file, directory, or literal value"), - Long: secretLong, - Example: secretExample, + Long: secretForGenericLong, + Example: secretForGenericExample, Run: func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(o.Complete(f, cmd, args)) cmdutil.CheckErr(o.Validate()) diff --git a/pkg/util/templates/templater.go b/pkg/util/templates/templater.go index 2e9f942a5..8fe181a05 100644 --- a/pkg/util/templates/templater.go +++ b/pkg/util/templates/templater.go @@ -126,6 +126,7 @@ func (templater *templater) templateFuncs(exposedFlags ...string) template.FuncM "isRootCmd": templater.isRootCmd, "optionsCmdFor": templater.optionsCmdFor, "usageLine": templater.usageLine, + "reverseParentsNames": templater.reverseParentsNames, "exposed": func(c *cobra.Command) *flag.FlagSet { exposed := flag.NewFlagSet("exposed", flag.ContinueOnError) if len(exposedFlags) > 0 { @@ -172,6 +173,15 @@ func (t *templater) rootCmdName(c *cobra.Command) string { return t.rootCmd(c).CommandPath() } +func (t *templater) reverseParentsNames(c *cobra.Command) []string { + reverseParentsNames := []string{} + parents := t.parents(c) + for i := len(parents) - 1; i >= 0; i-- { + reverseParentsNames = append(reverseParentsNames, parents[i].Name()) + } + return reverseParentsNames +} + func (t *templater) isRootCmd(c *cobra.Command) bool { return t.rootCmd(c) == c } diff --git a/pkg/util/templates/templates.go b/pkg/util/templates/templates.go index 9f3b75b57..454695c0b 100644 --- a/pkg/util/templates/templates.go +++ b/pkg/util/templates/templates.go @@ -28,7 +28,8 @@ const ( `{{$visibleFlags := visibleFlags (flagsNotIntersected .LocalFlags .PersistentFlags)}}` + `{{$explicitlyExposedFlags := exposed .}}` + `{{$optionsCmdFor := optionsCmdFor .}}` + - `{{$usageLine := usageLine .}}` + `{{$usageLine := usageLine .}}` + + `{{$reverseParentsNames := reverseParentsNames .}}` // SectionAliases is the help template section that displays command aliases. SectionAliases = `{{if gt .Aliases 0}}Aliases: @@ -61,7 +62,7 @@ const ( {{end}}` // SectionTipsHelp is the help template section that displays the '--help' hint. - SectionTipsHelp = `{{if .HasSubCommands}}Use "{{$rootCmd}} --help" for more information about a given command. + SectionTipsHelp = `{{if .HasSubCommands}}Use "{{range $reverseParentsNames}}{{.}} {{end}} --help" for more information about a given command. {{end}}` // SectionTipsGlobalOptions is the help template section that displays the 'options' hint for displaying global flags.