Files
LazyPM/internal/commands/issues/completion.go
Robin Olsen d900a5fcd3 Merge pull request #75 from LazyBachelor/LPM-140
LPM-140 The Sprinting Update
Adds sprint support across the web UI (board + issue detail), TUI kanban, CLI/REPL, and the Beads-backed storage layer.

Changes:

Introduces sprint entities in storage and exposes sprint operations via IssueService.
Updates web board to support backlog vs. sprint columns, sprint selection, and sprint creation routes.
Updates TUI kanban to show backlog + sprint columns and adds sprint selection/creation actions.
2026-03-23 19:26:04 +01:00

51 lines
1.5 KiB
Go

package issues
import (
"context"
"strings"
"github.com/LazyBachelor/LazyPM/internal/models"
"github.com/spf13/cobra"
)
// Variables for completion options and functions.
var (
typeOptions = []string{"bug", "feature", "task", "chore"}
statusOptions = []string{"open", "closed", "in_progress", "blocked"}
priorityRange = []string{"0", "1", "2", "3", "4"}
)
// 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)
var ids []string
for _, issue := range issues {
ids = append(ids, issue.ID)
}
return ids, cobra.ShellCompDirectiveNoFileComp
}
// GetIssueCompletions fetches issues matching the toComplete string for shell completion.
func GetIssueCompletions(ctx context.Context, toComplete string) ([]*models.Issue, cobra.ShellCompDirective) {
app := AppFromContext(ctx)
if app == nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
issues, err := app.Issues.SearchIssues(ctx, "", models.IssueFilter{})
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
var completions []*models.Issue
for _, issue := range issues {
if strings.HasPrefix(issue.ID, toComplete) {
completions = append(completions, issue)
} else if strings.HasPrefix(issue.Title, toComplete) {
completions = append(completions, issue)
}
}
return completions, cobra.ShellCompDirectiveNoFileComp
}