From f91d33e2f05a2e4f133ac74b8a67c72ef74a5e89 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Wed, 18 Feb 2026 13:19:16 +0100 Subject: [PATCH] add list command to view available tasks move init to a taks.go for centralization --- cmd/survey/cmd.go | 12 ++++++++++++ cmd/survey/tasks/codingTask.go | 6 ------ cmd/survey/tasks/createIssue.go | 6 ------ cmd/survey/tasks/tasks.go | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 cmd/survey/tasks/tasks.go diff --git a/cmd/survey/cmd.go b/cmd/survey/cmd.go index 184fa4a..6243cc1 100644 --- a/cmd/survey/cmd.go +++ b/cmd/survey/cmd.go @@ -77,10 +77,22 @@ func runStartCmd(cmd *cobra.Command, args []string) error { 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() { rootCmd.CompletionOptions.DisableDefaultCmd = true startCmd.Flags().StringVarP(&interfaceType, "interface", "i", "tui", "Specify interface.") startCmd.Flags().IntVarP(&stage, "stage", "s", 1, "Run stage directly") rootCmd.AddCommand(startCmd) rootCmd.AddCommand(submitCmd) + rootCmd.AddCommand(listCmd) } diff --git a/cmd/survey/tasks/codingTask.go b/cmd/survey/tasks/codingTask.go index 9c1966e..7464796 100644 --- a/cmd/survey/tasks/codingTask.go +++ b/cmd/survey/tasks/codingTask.go @@ -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. 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 { svc *service.Services } diff --git a/cmd/survey/tasks/createIssue.go b/cmd/survey/tasks/createIssue.go index ffdf6fa..f4b358f 100644 --- a/cmd/survey/tasks/createIssue.go +++ b/cmd/survey/tasks/createIssue.go @@ -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. 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 { svc *service.Services } diff --git a/cmd/survey/tasks/tasks.go b/cmd/survey/tasks/tasks.go new file mode 100644 index 0000000..cc65a0b --- /dev/null +++ b/cmd/survey/tasks/tasks.go @@ -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) + }) +}