diff --git a/cmd/survey.go b/cmd/survey.go deleted file mode 100644 index a6a9922..0000000 --- a/cmd/survey.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - "fmt" - "os" - - "github.com/LazyBachelor/LazyPM/pkg" - "github.com/LazyBachelor/LazyPM/pkg/cli" - "github.com/LazyBachelor/LazyPM/pkg/cli/repl" - "github.com/LazyBachelor/LazyPM/pkg/tui" - "github.com/LazyBachelor/LazyPM/pkg/web" -) - -func main() { - config := pkg.SurveyConfig{ - RootCmd: "pm", - WebAddress: "localhost:8080", - IssuePrefix: "pm", - BeadsDBPath: "./.pm/db.db", - StatisticsStoragePath: "./.pm/stats.json", - } - - ctx := context.Background() - var err error - - switch os.Args[1] { - case "tui": - err = tui.Run(ctx, config) - case "cli": - err = cli.RunWithArgs(ctx, config, os.Args[2:]) - case "repl": - err = repl.RunREPL(ctx, config) - case "web": - err = web.Run(ctx, config) - default: - err = fmt.Errorf("unknown command: %s", os.Args[1]) - } - - if err != nil { - fmt.Fprintf(os.Stderr, "Error: %v\n", err) - os.Exit(1) - } -} diff --git a/cmd/survey/assets/intro.toml b/cmd/survey/assets/intro.toml new file mode 100644 index 0000000..845895b --- /dev/null +++ b/cmd/survey/assets/intro.toml @@ -0,0 +1,10 @@ +Title = "Welcome to the PM CLI Survey!" +Description = "Thank you for taking the time to participate in our survey. Your feedback is crucial in helping us improve the PM CLI and make it a more effective tool for project management. Please read the following information about the PM CLI before proceeding with the survey." + +[About] +Title = "About the PM CLI" +Description = "YO PM CLI is a tool designed to help you manage your projects more efficiently. It provides features such as task management, issue tracking, and team collaboration, all through a simple command-line interface." + +[Disclaimer] +Title = "Disclaimer" +Description = "Please note that the PM CLI is currently in its early stages of development. We are actively seeking feedback to improve the tool, so your input is highly valuable to us. By participating in this survey, you agree to provide honest and constructive feedback to help shape the future of the PM CLI." \ No newline at end of file diff --git a/cmd/survey/forms/intro.go b/cmd/survey/forms/intro.go new file mode 100644 index 0000000..fd4be96 --- /dev/null +++ b/cmd/survey/forms/intro.go @@ -0,0 +1,56 @@ +package forms + +import ( + "embed" + "fmt" + + "github.com/BurntSushi/toml" + "github.com/charmbracelet/huh" +) + +type Introduction struct { + Title string + Description string + About struct { + Title string + Description string + } + Disclaimer struct { + Title string + Description string + } +} + +func NewIntroduction(fs embed.FS) (Introduction, error) { + var intro Introduction + if _, err := toml.DecodeFS(fs, "assets/intro.toml", &intro); err != nil { + return Introduction{}, err + } + + return intro, nil +} + +func (i Introduction) Run() error { + fmt.Print("\033[H\033[2J") + + form := huh.NewForm( + huh.NewGroup( + huh.NewNote(). + Title(i.Title). + Description(i.Description), + ), + huh.NewGroup( + huh.NewNote(). + Title(i.About.Title). + Description(i.About.Description), + ), + huh.NewGroup( + huh.NewNote(). + Title(i.Disclaimer.Title). + Description(i.Disclaimer.Description), + ), + ).WithLayout(huh.LayoutStack). + WithTheme(huh.ThemeBase16()) + + return form.Run() +} diff --git a/cmd/survey/survey.go b/cmd/survey/survey.go new file mode 100644 index 0000000..71cd91f --- /dev/null +++ b/cmd/survey/survey.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "embed" + "fmt" + "os" + + "github.com/LazyBachelor/LazyPM/cmd/survey/forms" + "github.com/LazyBachelor/LazyPM/pkg" + "github.com/LazyBachelor/LazyPM/pkg/cli/repl" + "github.com/LazyBachelor/LazyPM/pkg/tui" + "github.com/LazyBachelor/LazyPM/pkg/web" + "github.com/charmbracelet/huh" +) + +//go:embed assets/* +var assetsFS embed.FS + +func main() { + intro, err := forms.NewIntroduction(assetsFS) + if err != nil { + fmt.Fprintf(os.Stderr, "Error loading introduction: %v\n", err) + os.Exit(1) + } + + if err := intro.Run(); err != nil { + fmt.Fprintf(os.Stderr, "Error running introduction: %v\n", err) + os.Exit(1) + } + + var selected string + prompt := huh.NewSelect[string]().Options( + huh.NewOption("Start CLI in REPL Mode", "repl"), + huh.NewOption("Start Web Interface", "web"), + huh.NewOption("Start TUI Interface", "tui"), + ).Value(&selected).WithTheme(huh.ThemeBase16()) + + if err := prompt.Run(); err != nil { + fmt.Fprintf(os.Stderr, "Error running prompt: %v\n", err) + os.Exit(1) + } + + config := pkg.SurveyConfig{ + RootCmd: "pm", + IssuePrefix: "pm", + BeadsDBPath: "./.pm/db.db", + StatisticsStoragePath: "./.pm/stats.json", + WebAddress: "localhost:8080", + } + + ctx := context.Background() + switch selected { + case "repl": + fmt.Println("Starting CLI in REPL mode...") + err = repl.RunREPL(ctx, config) + case "web": + fmt.Println("Starting Web Interface...") + err = web.Run(ctx, config) + case "tui": + fmt.Println("Starting TUI Interface...") + err = tui.Run(ctx, config) + default: + fmt.Println("Invalid selection. Exiting.") + } + + if err != nil { + fmt.Fprintf(os.Stderr, "Error running selected interface: %v\n", err) + os.Exit(1) + } + +} diff --git a/go.mod b/go.mod index 04c7cad..fad1402 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/LazyBachelor/LazyPM go 1.25.6 require ( + github.com/BurntSushi/toml v1.6.0 github.com/Dicklesworthstone/beads_viewer v0.14.3 github.com/NYTimes/gziphandler v1.1.1 github.com/a-h/templ v0.3.977 diff --git a/go.sum b/go.sum index dba30f8..14f3663 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dk git.sr.ht/~sbinet/gg v0.7.0 h1:YmNf7YKd7diDMTPm86hZa1EM3pbkOyD/zzjl0LZUdNM= git.sr.ht/~sbinet/gg v0.7.0/go.mod h1:VYeli15tpMM4EvqlivlVbbyvWZlOU+EZn4XZmfBGUdM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/Dicklesworthstone/beads_viewer v0.14.3 h1:DxeICQESYvrH+8cn/Pymlb7l9Xm5XL6BTyi6KWiY3H8= github.com/Dicklesworthstone/beads_viewer v0.14.3/go.mod h1:5oEV2h+PVmBTdQpOijnlWMlG/qi+zheXbgOUlqKmWKI= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=