add so u can choose interface
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/repl"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/tui"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/web"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,6 +17,7 @@ var startCmd = &cobra.Command{
|
|||||||
Use: "start",
|
Use: "start",
|
||||||
Short: "Start the user survey",
|
Short: "Start the user survey",
|
||||||
RunE: runStartCmd,
|
RunE: runStartCmd,
|
||||||
|
Args: cobra.MinimumNArgs(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
func runStartCmd(cmd *cobra.Command, args []string) error {
|
func runStartCmd(cmd *cobra.Command, args []string) error {
|
||||||
@@ -29,6 +34,16 @@ func runStartCmd(cmd *cobra.Command, args []string) error {
|
|||||||
surveyTasks := initTasks(svc)
|
surveyTasks := initTasks(svc)
|
||||||
interfaces := initInterfaces()
|
interfaces := initInterfaces()
|
||||||
|
|
||||||
|
if args[0] == "tui" {
|
||||||
|
interfaces = []task.Interface{tui.NewTui()}
|
||||||
|
}
|
||||||
|
if args[0] == "repl" {
|
||||||
|
interfaces = []task.Interface{repl.NewRepl()}
|
||||||
|
}
|
||||||
|
if args[0] == "web" {
|
||||||
|
interfaces = []task.Interface{web.NewWeb()}
|
||||||
|
}
|
||||||
|
|
||||||
if err := taskLoop(cmd.Context(), surveyTasks, interfaces); err != nil {
|
if err := taskLoop(cmd.Context(), surveyTasks, interfaces); err != nil {
|
||||||
return returnIfUserQuit(err, "task loop failed")
|
return returnIfUserQuit(err, "task loop failed")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user