Completion: Capitalize short desc, and remove extra space from long (#1455)

This commit is contained in:
Frank Chiarulli Jr 2021-12-07 17:52:50 -05:00 committed by GitHub
parent dd40ab071f
commit c3573e220c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 14 deletions

View File

@ -599,9 +599,8 @@ func (c *Command) initDefaultCompletionCmd() {
completionCmd := &Command{ completionCmd := &Command{
Use: compCmdName, Use: compCmdName,
Short: "generate the autocompletion script for the specified shell", Short: "Generate the autocompletion script for the specified shell",
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for %[1]s for the specified shell.
Generate the autocompletion script for %[1]s for the specified shell.
See each sub-command's help for details on how to use the generated script. See each sub-command's help for details on how to use the generated script.
`, c.Root().Name()), `, c.Root().Name()),
Args: NoArgs, Args: NoArgs,
@ -611,12 +610,11 @@ See each sub-command's help for details on how to use the generated script.
out := c.OutOrStdout() out := c.OutOrStdout()
noDesc := c.CompletionOptions.DisableDescriptions noDesc := c.CompletionOptions.DisableDescriptions
shortDesc := "generate the autocompletion script for %s" shortDesc := "Generate the autocompletion script for %s"
bash := &Command{ bash := &Command{
Use: "bash", Use: "bash",
Short: fmt.Sprintf(shortDesc, "bash"), Short: fmt.Sprintf(shortDesc, "bash"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the bash shell.
Generate the autocompletion script for the bash shell.
This script depends on the 'bash-completion' package. This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager. If it is not installed already, you can install it via your OS's package manager.
@ -651,8 +649,7 @@ You will need to start a new shell for this setup to take effect.
zsh := &Command{ zsh := &Command{
Use: "zsh", Use: "zsh",
Short: fmt.Sprintf(shortDesc, "zsh"), Short: fmt.Sprintf(shortDesc, "zsh"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the zsh shell.
Generate the autocompletion script for the zsh shell.
If shell completion is not already enabled in your environment you will need If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once: to enable it. You can execute the following once:
@ -687,8 +684,7 @@ You will need to start a new shell for this setup to take effect.
fish := &Command{ fish := &Command{
Use: "fish", Use: "fish",
Short: fmt.Sprintf(shortDesc, "fish"), Short: fmt.Sprintf(shortDesc, "fish"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the fish shell.
Generate the autocompletion script for the fish shell.
To load completions in your current shell session: To load completions in your current shell session:
@ -713,8 +709,7 @@ You will need to start a new shell for this setup to take effect.
powershell := &Command{ powershell := &Command{
Use: "powershell", Use: "powershell",
Short: fmt.Sprintf(shortDesc, "powershell"), Short: fmt.Sprintf(shortDesc, "powershell"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for powershell.
Generate the autocompletion script for powershell.
To load completions in your current shell session: To load completions in your current shell session:

View File

@ -125,7 +125,7 @@ func TestCmdNameCompletionInGo(t *testing.T) {
expected = strings.Join([]string{ expected = strings.Join([]string{
"aliased\tA command with aliases", "aliased\tA command with aliases",
"completion\tgenerate the autocompletion script for the specified shell", "completion\tGenerate the autocompletion script for the specified shell",
"firstChild\tFirst command", "firstChild\tFirst command",
"help\tHelp about any command", "help\tHelp about any command",
"secondChild", "secondChild",
@ -580,7 +580,7 @@ func TestFlagNameCompletionInGoWithDesc(t *testing.T) {
expected := strings.Join([]string{ expected := strings.Join([]string{
"childCmd\tfirst command", "childCmd\tfirst command",
"completion\tgenerate the autocompletion script for the specified shell", "completion\tGenerate the autocompletion script for the specified shell",
"help\tHelp about any command", "help\tHelp about any command",
":4", ":4",
"Completion ended with directive: ShellCompDirectiveNoFileComp", ""}, "\n") "Completion ended with directive: ShellCompDirectiveNoFileComp", ""}, "\n")