From 84c0ad22862a91b79c2031976fd8f3764adaa0ae Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Sun, 8 Feb 2026 12:29:06 +0100 Subject: [PATCH] add completionFunc for reducing boilerplate for command implementatinos --- pkg/cli/commands/completion.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/cli/commands/completion.go b/pkg/cli/commands/completion.go index ff13107..af34c20 100644 --- a/pkg/cli/commands/completion.go +++ b/pkg/cli/commands/completion.go @@ -8,6 +8,19 @@ import ( "github.com/spf13/cobra" ) +var ( + typeOptions = []string{"bug", "feature", "task"} + statusOptions = []string{"open", "closed", "in_progress"} + priorityRange = []string{"0", "1", "2", "3", "4"} +) + +// completionFunc returns a function that provides shell completion for the given options. +func completionFunc(options []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { + return func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { + return options, cobra.ShellCompDirectiveDefault + } +} + // completeIssues provides shell completion for issue IDs and titles. func completeIssues(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { issues, _ := GetIssueCompletions(cmd.Context(), toComplete)