From db8204dc56499829629aa286251ed7c40c688652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 21 Jul 2021 15:27:03 +0200 Subject: [PATCH] Allow space to be added after completing `issue/pr list --state` values The "nospace" directive instructs the shell completion logic to avoid adding a space after completing the word. However, this feature was broken in an older Cobra, and users still saw a space character added. In most case we want the space because we anticipate that the user might want to add extra arguments to the command. --- pkg/cmd/issue/list/list.go | 2 +- pkg/cmd/pr/list/list.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/issue/list/list.go b/pkg/cmd/issue/list/list.go index 0171b1a38..d2e34380b 100644 --- a/pkg/cmd/issue/list/list.go +++ b/pkg/cmd/issue/list/list.go @@ -83,7 +83,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels") cmd.Flags().StringVarP(&opts.State, "state", "s", "open", "Filter by state: {open|closed|all}") _ = cmd.RegisterFlagCompletionFunc("state", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return []string{"open", "closed", "all"}, cobra.ShellCompDirectiveNoSpace + return []string{"open", "closed", "all"}, cobra.ShellCompDirectiveNoFileComp }) cmd.Flags().IntVarP(&opts.LimitResults, "limit", "L", 30, "Maximum number of issues to fetch") cmd.Flags().StringVarP(&opts.Author, "author", "A", "", "Filter by author") diff --git a/pkg/cmd/pr/list/list.go b/pkg/cmd/pr/list/list.go index 67f8f36d6..11a365cee 100644 --- a/pkg/cmd/pr/list/list.go +++ b/pkg/cmd/pr/list/list.go @@ -85,7 +85,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman cmd.Flags().IntVarP(&opts.LimitResults, "limit", "L", 30, "Maximum number of items to fetch") cmd.Flags().StringVarP(&opts.State, "state", "s", "open", "Filter by state: {open|closed|merged|all}") _ = cmd.RegisterFlagCompletionFunc("state", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return []string{"open", "closed", "merged", "all"}, cobra.ShellCompDirectiveNoSpace + return []string{"open", "closed", "merged", "all"}, cobra.ShellCompDirectiveNoFileComp }) cmd.Flags().StringVarP(&opts.BaseBranch, "base", "B", "", "Filter by base branch") cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels")