add completions to survey
This commit is contained in:
@@ -36,14 +36,6 @@ func init() {
|
||||
task.RegisterInterface("web", web.NewWeb())
|
||||
task.RegisterInterface("repl", repl.NewRepl())
|
||||
|
||||
surveyCmd.StartCmd.RunE = runStartCmd
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.StartCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.SubmitCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.StatusCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.ListTasksCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.ListInterfacesCmd)
|
||||
surveyCmd.RootCmd.AddCommand(issuesCmd.RootCmd)
|
||||
|
||||
task.RegisterTask("create_issue", func(app *service.App) task.Tasker {
|
||||
return tasks.NewCreateIssueTask(app)
|
||||
})
|
||||
@@ -81,4 +73,11 @@ func init() {
|
||||
return tasks.NewBacklogRefinementTask(app)
|
||||
})
|
||||
|
||||
surveyCmd.StartCmd.RunE = runStartCmd
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.StartCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.SubmitCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.StatusCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.ListTasksCmd)
|
||||
surveyCmd.RootCmd.AddCommand(surveyCmd.ListInterfacesCmd)
|
||||
surveyCmd.RootCmd.AddCommand(issuesCmd.RootCmd)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package surveyCmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
InterfaceType string
|
||||
@@ -16,4 +20,6 @@ var StartCmd = &cobra.Command{
|
||||
func init() {
|
||||
StartCmd.Flags().StringVarP(&Task, "task", "t", "", "Specify task.")
|
||||
StartCmd.Flags().StringVarP(&InterfaceType, "interface", "i", "", "Specify interface.")
|
||||
StartCmd.RegisterFlagCompletionFunc("task", commands.CompletionFunc(task.ListTasks()))
|
||||
StartCmd.RegisterFlagCompletionFunc("interface", commands.CompletionFunc(task.ListInterfaces()))
|
||||
}
|
||||
|
||||
10
internal/commands/util.go
Normal file
10
internal/commands/util.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package commands
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,13 @@ import (
|
||||
"github.com/steveyegge/beads"
|
||||
)
|
||||
|
||||
// ValidationFeedback holds task validation status
|
||||
type ValidationFeedback struct {
|
||||
Success bool
|
||||
Message string
|
||||
}
|
||||
|
||||
type App struct {
|
||||
Config Config
|
||||
Issues IssueService
|
||||
Stats StatsService
|
||||
|
||||
Logger *slog.Logger
|
||||
|
||||
CurrentFeedback *ValidationFeedback
|
||||
}
|
||||
|
||||
@@ -33,3 +29,8 @@ type StatsService interface {
|
||||
Save(ctx context.Context) error
|
||||
GetStatistics() (models.Statistics, error)
|
||||
}
|
||||
|
||||
type ValidationFeedback struct {
|
||||
Success bool
|
||||
Message string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user