refactor to decouple commands form entrypoint for reusability and centralizing commands.
Increase reusability and composition
This commit is contained in:
17
internal/commands/survey/list.go
Normal file
17
internal/commands/survey/list.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package surveyCmd
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
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
|
||||
},
|
||||
}
|
||||
29
internal/commands/survey/root.go
Normal file
29
internal/commands/survey/root.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package surveyCmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
InterfaceType string
|
||||
Task int
|
||||
)
|
||||
|
||||
// RootCmd is the base command for the survey CLI.
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "survey",
|
||||
Long: `Project Management Interface Survey
|
||||
|
||||
Thank you for participating in our survey!
|
||||
|
||||
We are gathering data on how users interact with different task management interfaces to better understand their preferences and compare their usability.
|
||||
This survey will present you with a series of tasks to complete using various interfaces, including command-line, web-based, and terminal user interfaces.
|
||||
|
||||
Please answer the questions honestly and to the best of your ability.
|
||||
Your responses will be kept confidential and used solely for research purposes.`}
|
||||
|
||||
func init() {
|
||||
RootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
StartCmd.Flags().StringVarP(&InterfaceType, "interface", "i", "tui", "Specify interface.")
|
||||
StartCmd.Flags().IntVarP(&Task, "task", "t", 1, "Run task directly")
|
||||
}
|
||||
9
internal/commands/survey/start.go
Normal file
9
internal/commands/survey/start.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package surveyCmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
// StartCmd is the start command - RunE is set in cmd/survey/
|
||||
var StartCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the user survey",
|
||||
}
|
||||
30
internal/commands/survey/status.go
Normal file
30
internal/commands/survey/status.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package surveyCmd
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands/issues"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// StatusCmd displays the current task validation status
|
||||
var StatusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "Check task validation status",
|
||||
Long: "Displays the current task validation status and feedback.",
|
||||
RunE: runStatusCmd,
|
||||
}
|
||||
|
||||
func runStatusCmd(cmd *cobra.Command, args []string) error {
|
||||
app := issuesCmd.AppFromContext(cmd.Context())
|
||||
if app == nil || app.CurrentFeedback == nil {
|
||||
cmd.Println("No validation status available.")
|
||||
return nil
|
||||
}
|
||||
|
||||
if app.CurrentFeedback.Message == "" {
|
||||
cmd.Println("No validation status available yet.")
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd.Print(app.CurrentFeedback.Message)
|
||||
return nil
|
||||
}
|
||||
12
internal/commands/survey/submit.go
Normal file
12
internal/commands/survey/submit.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package surveyCmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var SubmitCmd = &cobra.Command{
|
||||
Use: "submit",
|
||||
Short: "Submit your survey responses",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cmd.Println("Submitting responses and metrics...")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user