add list command to view available tasks

move init to a taks.go for centralization
This commit is contained in:
Robin Olsen
2026-02-18 13:19:16 +01:00
parent 23747fb799
commit f91d33e2f0
4 changed files with 28 additions and 12 deletions

View File

@@ -77,10 +77,22 @@ func runStartCmd(cmd *cobra.Command, args []string) error {
return nil return nil
} }
var listCmd = &cobra.Command{
Use: "list",
Short: "List available tasks",
RunE: func(cmd *cobra.Command, args []string) error {
for i, name := range task.List() {
cmd.Printf("%d. %s\n", i+1, name)
}
return nil
},
}
func init() { func init() {
rootCmd.CompletionOptions.DisableDefaultCmd = true rootCmd.CompletionOptions.DisableDefaultCmd = true
startCmd.Flags().StringVarP(&interfaceType, "interface", "i", "tui", "Specify interface.") startCmd.Flags().StringVarP(&interfaceType, "interface", "i", "tui", "Specify interface.")
startCmd.Flags().IntVarP(&stage, "stage", "s", 1, "Run stage directly") startCmd.Flags().IntVarP(&stage, "stage", "s", 1, "Run stage directly")
rootCmd.AddCommand(startCmd) rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(submitCmd) rootCmd.AddCommand(submitCmd)
rootCmd.AddCommand(listCmd)
} }

View File

@@ -14,12 +14,6 @@ const codingDescription = `You are tasked with writing a simple function.
Write a function that takes two integers and returns their sum. Write a function that takes two integers and returns their sum.
The function should be named "Add" and be part of the "coding" package.` The function should be named "Add" and be part of the "coding" package.`
func init() {
task.Register("coding_task", func(svc *service.Services) task.Tasker {
return NewCodingTask(svc)
})
}
type CodingTask struct { type CodingTask struct {
svc *service.Services svc *service.Services
} }

View File

@@ -17,12 +17,6 @@ This task will test your ability to use the issue creation workflow effectively.
Assign this task to yourself and start creating the issue. Assign this task to yourself and start creating the issue.
Make sure to fill out all the necessary details, including the title, description, and assignee.` Make sure to fill out all the necessary details, including the title, description, and assignee.`
func init() {
task.Register("create_issue", func(svc *service.Services) task.Tasker {
return NewCreateIssueTask(svc)
})
}
type CreateIssueTask struct { type CreateIssueTask struct {
svc *service.Services svc *service.Services
} }

16
cmd/survey/tasks/tasks.go Normal file
View File

@@ -0,0 +1,16 @@
package tasks
import (
"github.com/LazyBachelor/LazyPM/internal/service"
"github.com/LazyBachelor/LazyPM/pkg/task"
)
func init() {
task.Register("create_issue", func(svc *service.Services) task.Tasker {
return NewCreateIssueTask(svc)
})
task.Register("coding_task", func(svc *service.Services) task.Tasker {
return NewCodingTask(svc)
})
}