add completions to survey
This commit is contained in:
@@ -15,13 +15,6 @@ var (
|
||||
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)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/charmbracelet/huh"
|
||||
|
||||
@@ -111,7 +112,7 @@ func init() {
|
||||
CreateCmd.Flags().StringVarP(&createFlags.issueType, "type", "t", "task", "Issue type(bug, feature, task)")
|
||||
CreateCmd.Flags().IntVarP(&createFlags.priority, "priority", "p", 0, "Issue priority(0-4)")
|
||||
|
||||
CreateCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||
CreateCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package issuesCmd
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -78,7 +79,7 @@ func init() {
|
||||
|
||||
ListCmd.Flags().IntVarP(&listFlags.limit, "limit", "l", 25, "Limit the number of issues returned")
|
||||
|
||||
ListCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||
ListCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package issuesCmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -61,9 +62,9 @@ func init() {
|
||||
UpdateCmd.Flags().StringVarP(&updateFlags.issueType, "type", "t", "", "New issue type(bug, feature, task)")
|
||||
UpdateCmd.Flags().IntVarP(&updateFlags.priority, "priority", "p", 0, "New issue priority(0-5)")
|
||||
|
||||
UpdateCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
func getUpdateValues(cmd *cobra.Command) (map[string]interface{}, error) {
|
||||
|
||||
Reference in New Issue
Block a user