add completions to survey
This commit is contained in:
@@ -36,14 +36,6 @@ func init() {
|
|||||||
task.RegisterInterface("web", web.NewWeb())
|
task.RegisterInterface("web", web.NewWeb())
|
||||||
task.RegisterInterface("repl", repl.NewRepl())
|
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 {
|
task.RegisterTask("create_issue", func(app *service.App) task.Tasker {
|
||||||
return tasks.NewCreateIssueTask(app)
|
return tasks.NewCreateIssueTask(app)
|
||||||
})
|
})
|
||||||
@@ -81,4 +73,11 @@ func init() {
|
|||||||
return tasks.NewBacklogRefinementTask(app)
|
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"}
|
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.
|
// completeIssues provides shell completion for issue IDs and titles.
|
||||||
func completeIssues(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
func completeIssues(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
issues, _ := GetIssueCompletions(cmd.Context(), toComplete)
|
issues, _ := GetIssueCompletions(cmd.Context(), toComplete)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/charmbracelet/huh"
|
"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().StringVarP(&createFlags.issueType, "type", "t", "task", "Issue type(bug, feature, task)")
|
||||||
CreateCmd.Flags().IntVarP(&createFlags.priority, "priority", "p", 0, "Issue priority(0-4)")
|
CreateCmd.Flags().IntVarP(&createFlags.priority, "priority", "p", 0, "Issue priority(0-4)")
|
||||||
|
|
||||||
CreateCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
CreateCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||||
CreateCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
CreateCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||||
CreateCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
CreateCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package issuesCmd
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/spf13/cobra"
|
"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.Flags().IntVarP(&listFlags.limit, "limit", "l", 25, "Limit the number of issues returned")
|
||||||
|
|
||||||
ListCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
ListCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||||
ListCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
ListCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||||
ListCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
ListCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package issuesCmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/commands"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/spf13/cobra"
|
"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().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.Flags().IntVarP(&updateFlags.priority, "priority", "p", 0, "New issue priority(0-5)")
|
||||||
|
|
||||||
UpdateCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
UpdateCmd.RegisterFlagCompletionFunc("type", commands.CompletionFunc(typeOptions))
|
||||||
UpdateCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
UpdateCmd.RegisterFlagCompletionFunc("status", commands.CompletionFunc(statusOptions))
|
||||||
UpdateCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
UpdateCmd.RegisterFlagCompletionFunc("priority", commands.CompletionFunc(priorityRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUpdateValues(cmd *cobra.Command) (map[string]interface{}, error) {
|
func getUpdateValues(cmd *cobra.Command) (map[string]interface{}, error) {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package surveyCmd
|
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 (
|
var (
|
||||||
InterfaceType string
|
InterfaceType string
|
||||||
@@ -16,4 +20,6 @@ var StartCmd = &cobra.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
StartCmd.Flags().StringVarP(&Task, "task", "t", "", "Specify task.")
|
StartCmd.Flags().StringVarP(&Task, "task", "t", "", "Specify task.")
|
||||||
StartCmd.Flags().StringVarP(&InterfaceType, "interface", "i", "", "Specify interface.")
|
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"
|
"github.com/steveyegge/beads"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidationFeedback holds task validation status
|
|
||||||
type ValidationFeedback struct {
|
|
||||||
Success bool
|
|
||||||
Message string
|
|
||||||
}
|
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
Config Config
|
Config Config
|
||||||
Issues IssueService
|
Issues IssueService
|
||||||
Stats StatsService
|
Stats StatsService
|
||||||
Logger *slog.Logger
|
|
||||||
|
Logger *slog.Logger
|
||||||
|
|
||||||
CurrentFeedback *ValidationFeedback
|
CurrentFeedback *ValidationFeedback
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,3 +29,8 @@ type StatsService interface {
|
|||||||
Save(ctx context.Context) error
|
Save(ctx context.Context) error
|
||||||
GetStatistics() (models.Statistics, error)
|
GetStatistics() (models.Statistics, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ValidationFeedback struct {
|
||||||
|
Success bool
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user