Merge remote-tracking branch 'origin/main' into LPM-32
This commit is contained in:
4
Makefile
4
Makefile
@@ -7,12 +7,12 @@ clean:
|
|||||||
go clean
|
go clean
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o ./bin/cli ./cmd/cli
|
go build -o ./bin/pm ./cmd/pm
|
||||||
go build -o ./bin/tui ./cmd/tui
|
go build -o ./bin/tui ./cmd/tui
|
||||||
go build -o ./bin/web ./cmd/web
|
go build -o ./bin/web ./cmd/web
|
||||||
|
|
||||||
cli:
|
cli:
|
||||||
go run ./cmd/cli
|
go run ./cmd/pm
|
||||||
|
|
||||||
tui:
|
tui:
|
||||||
go run ./cmd/tui
|
go run ./cmd/tui
|
||||||
|
|||||||
@@ -5,14 +5,20 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/pkg"
|
"github.com/LazyBachelor/LazyPM/pkg"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/cli"
|
"github.com/LazyBachelor/LazyPM/pkg/cli"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/repl"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/tui"
|
"github.com/LazyBachelor/LazyPM/pkg/tui"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/web"
|
"github.com/LazyBachelor/LazyPM/pkg/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config := pkg.SurveyConfig{
|
config := pkg.SurveyConfig{
|
||||||
|
RootCmd: "pm",
|
||||||
WebAddress: "localhost:8080",
|
WebAddress: "localhost:8080",
|
||||||
IssuePrefix: "pm",
|
IssuePrefix: "pm",
|
||||||
BeadsDBPath: "./.pm/db.db",
|
BeadsDBPath: "./.pm/db.db",
|
||||||
@@ -26,7 +32,9 @@ func main() {
|
|||||||
case "tui":
|
case "tui":
|
||||||
_, err = tui.Run(ctx, config)
|
_, err = tui.Run(ctx, config)
|
||||||
case "cli":
|
case "cli":
|
||||||
err = cli.Run(ctx, config)
|
err = cli.RunWithArgs(ctx, config, os.Args[2:])
|
||||||
|
case "repl":
|
||||||
|
err = repl.RunREPL(ctx, config)
|
||||||
case "web":
|
case "web":
|
||||||
err = web.Run(ctx, config)
|
err = web.Run(ctx, config)
|
||||||
default:
|
default:
|
||||||
|
|||||||
19
go.mod
19
go.mod
@@ -6,16 +6,22 @@ require (
|
|||||||
github.com/Dicklesworthstone/beads_viewer v0.14.3
|
github.com/Dicklesworthstone/beads_viewer v0.14.3
|
||||||
github.com/NYTimes/gziphandler v1.1.1
|
github.com/NYTimes/gziphandler v1.1.1
|
||||||
github.com/a-h/templ v0.3.977
|
github.com/a-h/templ v0.3.977
|
||||||
|
github.com/c-bata/go-prompt v0.2.6
|
||||||
github.com/charmbracelet/bubbles v0.21.1
|
github.com/charmbracelet/bubbles v0.21.1
|
||||||
github.com/charmbracelet/bubbletea v1.3.10
|
github.com/charmbracelet/bubbletea v1.3.10
|
||||||
|
github.com/charmbracelet/fang v0.4.4
|
||||||
|
github.com/charmbracelet/huh v0.8.0
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
|
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/muesli/reflow v0.3.0
|
||||||
github.com/rs/cors v1.11.1
|
github.com/rs/cors v1.11.1
|
||||||
github.com/spf13/cobra v1.10.2
|
github.com/spf13/cobra v1.10.2
|
||||||
github.com/steveyegge/beads v0.49.3
|
github.com/steveyegge/beads v0.49.3
|
||||||
|
golang.org/x/term v0.39.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410 // indirect
|
||||||
git.sr.ht/~sbinet/gg v0.7.0 // indirect
|
git.sr.ht/~sbinet/gg v0.7.0 // indirect
|
||||||
github.com/a-h/parse v0.0.0-20250122154542-74294addb73e // indirect
|
github.com/a-h/parse v0.0.0-20250122154542-74294addb73e // indirect
|
||||||
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
|
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
|
||||||
@@ -28,12 +34,15 @@ require (
|
|||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.4.1 // indirect
|
github.com/charmbracelet/colorprofile v0.4.1 // indirect
|
||||||
github.com/charmbracelet/glamour v0.10.0 // indirect
|
github.com/charmbracelet/glamour v0.10.0 // indirect
|
||||||
github.com/charmbracelet/huh v0.8.0 // indirect
|
github.com/charmbracelet/ultraviolet v0.0.0-20251106190538-99ea45596692 // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.11.5 // indirect
|
github.com/charmbracelet/x/ansi v0.11.5 // indirect
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
||||||
|
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250603201427-c31516f43444 // indirect
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099 // indirect
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099 // indirect
|
||||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
||||||
github.com/cli/browser v1.3.0 // indirect
|
github.com/cli/browser v1.3.0 // indirect
|
||||||
github.com/clipperhouse/displaywidth v0.9.0 // indirect
|
github.com/clipperhouse/displaywidth v0.9.0 // indirect
|
||||||
github.com/clipperhouse/stringish v0.1.1 // indirect
|
github.com/clipperhouse/stringish v0.1.1 // indirect
|
||||||
@@ -54,17 +63,22 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.19 // indirect
|
github.com/mattn/go-runewidth v0.0.19 // indirect
|
||||||
|
github.com/mattn/go-tty v0.0.3 // indirect
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
github.com/muesli/reflow v0.3.0 // indirect
|
github.com/muesli/mango v0.1.0 // indirect
|
||||||
|
github.com/muesli/mango-cobra v1.2.0 // indirect
|
||||||
|
github.com/muesli/mango-pflag v0.1.0 // indirect
|
||||||
|
github.com/muesli/roff v0.1.0 // indirect
|
||||||
github.com/muesli/termenv v0.16.0 // indirect
|
github.com/muesli/termenv v0.16.0 // indirect
|
||||||
github.com/natefinch/atomic v1.0.1 // indirect
|
github.com/natefinch/atomic v1.0.1 // indirect
|
||||||
github.com/ncruces/go-sqlite3 v0.30.5 // indirect
|
github.com/ncruces/go-sqlite3 v0.30.5 // indirect
|
||||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||||
github.com/ncruces/julianday v1.0.0 // indirect
|
github.com/ncruces/julianday v1.0.0 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
|
github.com/pkg/term v1.2.0-beta.2 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.12.0 // indirect
|
github.com/sagikazarmark/locafero v0.12.0 // indirect
|
||||||
@@ -85,7 +99,6 @@ require (
|
|||||||
golang.org/x/net v0.49.0 // indirect
|
golang.org/x/net v0.49.0 // indirect
|
||||||
golang.org/x/sync v0.19.0 // indirect
|
golang.org/x/sync v0.19.0 // indirect
|
||||||
golang.org/x/sys v0.40.0 // indirect
|
golang.org/x/sys v0.40.0 // indirect
|
||||||
golang.org/x/term v0.39.0 // indirect
|
|
||||||
golang.org/x/text v0.33.0 // indirect
|
golang.org/x/text v0.33.0 // indirect
|
||||||
golang.org/x/tools v0.41.0 // indirect
|
golang.org/x/tools v0.41.0 // indirect
|
||||||
gonum.org/v1/gonum v0.17.0 // indirect
|
gonum.org/v1/gonum v0.17.0 // indirect
|
||||||
|
|||||||
43
go.sum
43
go.sum
@@ -1,3 +1,5 @@
|
|||||||
|
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410 h1:D9PbaszZYpB4nj+d6HTWr1onlmlyuGVNfL9gAi8iB3k=
|
||||||
|
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410/go.mod h1:1qZyvvVCenJO2M1ac2mX0yyiIZJoZmDM4DG4s0udJkU=
|
||||||
git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo=
|
git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo=
|
||||||
git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE=
|
git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE=
|
||||||
git.sr.ht/~sbinet/gg v0.7.0 h1:YmNf7YKd7diDMTPm86hZa1EM3pbkOyD/zzjl0LZUdNM=
|
git.sr.ht/~sbinet/gg v0.7.0 h1:YmNf7YKd7diDMTPm86hZa1EM3pbkOyD/zzjl0LZUdNM=
|
||||||
@@ -33,6 +35,8 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v
|
|||||||
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
|
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
|
||||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||||
|
github.com/c-bata/go-prompt v0.2.6 h1:POP+nrHE+DfLYx370bedwNhsqmpCUynWPxuHi0C5vZI=
|
||||||
|
github.com/c-bata/go-prompt v0.2.6/go.mod h1:/LMAke8wD2FsNu9EXNdHxNLbd9MedkPnCdfpU9wwHfY=
|
||||||
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
||||||
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
@@ -43,12 +47,16 @@ github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlv
|
|||||||
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
|
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
|
||||||
github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
|
github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
|
||||||
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
|
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
|
||||||
|
github.com/charmbracelet/fang v0.4.4 h1:G4qKxF6or/eTPgmAolwPuRNyuci3hTUGGX1rj1YkHJY=
|
||||||
|
github.com/charmbracelet/fang v0.4.4/go.mod h1:P5/DNb9DddQ0Z0dbc0P3ol4/ix5Po7Ofr2KMBfAqoCo=
|
||||||
github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY=
|
github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY=
|
||||||
github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk=
|
github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk=
|
||||||
github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY=
|
github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY=
|
||||||
github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE=
|
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE=
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=
|
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=
|
||||||
|
github.com/charmbracelet/ultraviolet v0.0.0-20251106190538-99ea45596692 h1:r/3jQZ1LjWW6ybp8HHfhrKrwHIWiJhUuY7wwYIWZulQ=
|
||||||
|
github.com/charmbracelet/ultraviolet v0.0.0-20251106190538-99ea45596692/go.mod h1:Y8B4DzWeTb0ama8l3+KyopZtkE8fZjwRQ3aEAPEXHE0=
|
||||||
github.com/charmbracelet/x/ansi v0.11.5 h1:NBWeBpj/lJPE3Q5l+Lusa4+mH6v7487OP8K0r1IhRg4=
|
github.com/charmbracelet/x/ansi v0.11.5 h1:NBWeBpj/lJPE3Q5l+Lusa4+mH6v7487OP8K0r1IhRg4=
|
||||||
github.com/charmbracelet/x/ansi v0.11.5/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
github.com/charmbracelet/x/ansi v0.11.5/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
||||||
@@ -57,8 +65,10 @@ github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSTh
|
|||||||
github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ=
|
github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ=
|
||||||
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
|
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
|
||||||
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
|
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
|
||||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
|
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250603201427-c31516f43444 h1:IJDiTgVE56gkAGfq0lBEloWgkXMk4hl/bmuPoicI4R0=
|
||||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
|
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250603201427-c31516f43444/go.mod h1:T9jr8CzFpjhFVHjNjKwbAD7KwBNyFnj2pntAO7F2zw0=
|
||||||
|
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
|
||||||
|
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099 h1:H09krOypYvXsPG4kYl+9J3tCRhST8WI3WEpXJELw+eg=
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099 h1:H09krOypYvXsPG4kYl+9J3tCRhST8WI3WEpXJELw+eg=
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA=
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260203065841-a1c614051099/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA=
|
||||||
github.com/charmbracelet/x/exp/strings v0.1.0 h1:i69S2XI7uG1u4NLGeJPSYU++Nmjvpo9nwd6aoEm7gkA=
|
github.com/charmbracelet/x/exp/strings v0.1.0 h1:i69S2XI7uG1u4NLGeJPSYU++Nmjvpo9nwd6aoEm7gkA=
|
||||||
@@ -67,6 +77,8 @@ github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSg
|
|||||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||||
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||||
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
||||||
github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI=
|
github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI=
|
||||||
github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4=
|
github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4=
|
||||||
github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo=
|
github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo=
|
||||||
@@ -127,15 +139,24 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
|
|||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
||||||
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||||
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||||
|
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
|
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
|
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
|
||||||
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||||
|
github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI=
|
||||||
|
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||||
@@ -144,8 +165,16 @@ github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D
|
|||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
|
||||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||||
|
github.com/muesli/mango v0.1.0 h1:DZQK45d2gGbql1arsYA4vfg4d7I9Hfx5rX/GCmzsAvI=
|
||||||
|
github.com/muesli/mango v0.1.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
|
||||||
|
github.com/muesli/mango-cobra v1.2.0 h1:DQvjzAM0PMZr85Iv9LIMaYISpTOliMEg+uMFtNbYvWg=
|
||||||
|
github.com/muesli/mango-cobra v1.2.0/go.mod h1:vMJL54QytZAJhCT13LPVDfkvCUJ5/4jNUKF/8NC2UjA=
|
||||||
|
github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe7Sg=
|
||||||
|
github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
|
||||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||||
|
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
|
||||||
|
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
|
||||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||||
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
|
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
|
||||||
@@ -158,6 +187,8 @@ github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt
|
|||||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
|
||||||
|
github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
@@ -223,11 +254,19 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||||||
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||||
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
|||||||
@@ -79,6 +79,18 @@ const (
|
|||||||
EventCompacted = beads.EventCompacted
|
EventCompacted = beads.EventCompacted
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func IssueString(issue Issue) string {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"ID: %s\nTitle: %s\nDescription: %s\nStatus: %s\nType: %s\nPriority: %d",
|
||||||
|
issue.ID,
|
||||||
|
issue.Title,
|
||||||
|
issue.Description,
|
||||||
|
issue.Status,
|
||||||
|
issue.IssueType,
|
||||||
|
issue.Priority,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func IssuesPtrToIssues(issuePtr []*Issue) []Issue {
|
func IssuesPtrToIssues(issuePtr []*Issue) []Issue {
|
||||||
issues := make([]Issue, 0, len(issuePtr))
|
issues := make([]Issue, 0, len(issuePtr))
|
||||||
for _, issuePtr := range issuePtr {
|
for _, issuePtr := range issuePtr {
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/storage"
|
"github.com/LazyBachelor/LazyPM/internal/storage"
|
||||||
|
"github.com/charmbracelet/huh"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/steveyegge/beads"
|
"github.com/steveyegge/beads"
|
||||||
@@ -28,6 +31,11 @@ type Services struct {
|
|||||||
func NewServices(ctx context.Context, config Config) (*Services, func(), error) {
|
func NewServices(ctx context.Context, config Config) (*Services, func(), error) {
|
||||||
var cleanupFuncs []func()
|
var cleanupFuncs []func()
|
||||||
|
|
||||||
|
if !initialized(config.BeadsDBPath) {
|
||||||
|
fmt.Println("PM is not initialized")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
store, err := beads.NewSQLiteStorage(ctx, config.BeadsDBPath)
|
store, err := beads.NewSQLiteStorage(ctx, config.BeadsDBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -63,3 +71,24 @@ func runCleanup(funcs []func()) {
|
|||||||
fn()
|
fn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initialized(beadsPath string) bool {
|
||||||
|
_, err := os.Stat(beadsPath)
|
||||||
|
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
var initialize bool
|
||||||
|
|
||||||
|
huh.NewForm(
|
||||||
|
huh.NewGroup(
|
||||||
|
huh.NewConfirm().Title("PM is not initialized in this directory!").
|
||||||
|
Description("Do you want to initialize it here?").
|
||||||
|
Value(&initialize),
|
||||||
|
),
|
||||||
|
).WithTheme(huh.ThemeBase16()).WithAccessible(true).Run()
|
||||||
|
|
||||||
|
if !initialize {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,23 +1,46 @@
|
|||||||
|
// Package cli provides the command-line interface for the PM System.
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
|
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
|
||||||
"context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CLIConfig is an alias for service.Config, used to configure the CLI.
|
||||||
type CLIConfig = service.Config
|
type CLIConfig = service.Config
|
||||||
|
|
||||||
|
// Run initializes the services and executes the CLI commands.
|
||||||
func Run(ctx context.Context, config CLIConfig) error {
|
func Run(ctx context.Context, config CLIConfig) error {
|
||||||
svc, cleanup, err := service.NewServices(ctx, config)
|
svc, cleanup, err := service.NewServices(ctx, config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
if err := commands.Execute(svc); err != nil {
|
commands.SetServices(svc)
|
||||||
|
|
||||||
|
if err := commands.Execute(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunWithArgs initializes the services and executes the CLI commands with the provided arguments.
|
||||||
|
func RunWithArgs(ctx context.Context, config CLIConfig, args []string) error {
|
||||||
|
svc, cleanup, err := service.NewServices(ctx, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
commands.SetServices(svc)
|
||||||
|
|
||||||
|
if err := commands.ExecuteArgs(args); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
pkg/cli/commands/close.go
Normal file
63
pkg/cli/commands/close.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/charmbracelet/huh"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// closeCmd represents the close command,
|
||||||
|
// which allows users to close an existing issue by its ID.
|
||||||
|
var closeCmd = &cobra.Command{
|
||||||
|
Use: "close [id]",
|
||||||
|
Short: "Close an existing issue",
|
||||||
|
Long: `Close an existing issue by its ID.`,
|
||||||
|
Example: `pm close pm-abc`,
|
||||||
|
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
RunE: runCloseCmd,
|
||||||
|
|
||||||
|
ValidArgsFunction: completeIssues,
|
||||||
|
}
|
||||||
|
|
||||||
|
// runCloseCmd executes the close command logic,
|
||||||
|
// which closes an issue by its ID after confirming with the user.
|
||||||
|
func runCloseCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
closeID := args[0]
|
||||||
|
|
||||||
|
if closeID == "" {
|
||||||
|
return fmt.Errorf("issue ID cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the issue to ensure it exists before closing.
|
||||||
|
issue, err := svc.Beads.GetIssue(cmd.Context(), closeID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error fetching issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue == nil {
|
||||||
|
return fmt.Errorf("issue with ID %s not found", closeID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ask for closing reason
|
||||||
|
if err = huh.NewInput().Value(&issue.CloseReason).
|
||||||
|
Title("Reason for closing the issue?").WithTheme(huh.ThemeBase()).Run(); err != nil {
|
||||||
|
return fmt.Errorf("error getting close reason: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the issue.
|
||||||
|
err = svc.Beads.CloseIssue(cmd.Context(), closeID, issue.CloseReason, "", "")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error closing issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Println("Closed issue with ID:", closeID)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// init function to set up the close command and its flags.
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(closeCmd)
|
||||||
|
}
|
||||||
56
pkg/cli/commands/completion.go
Normal file
56
pkg/cli/commands/completion.go
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Variables for completion options and functions.
|
||||||
|
var (
|
||||||
|
typeOptions = []string{"bug", "feature", "task"}
|
||||||
|
statusOptions = []string{"open", "closed", "in_progress"}
|
||||||
|
priorityRange = []string{"0", "1", "2", "3", "4"}
|
||||||
|
)
|
||||||
|
|
||||||
|
// completionFunc returns a function that provides shell completion for the given options.
|
||||||
|
func completionFunc(options []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return options, cobra.ShellCompDirectiveDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// completeIssues provides shell completion for issue IDs and titles.
|
||||||
|
func completeIssues(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
issues, _ := GetIssueCompletions(cmd.Context(), toComplete)
|
||||||
|
var ids []string
|
||||||
|
for _, issue := range issues {
|
||||||
|
ids = append(ids, issue.ID)
|
||||||
|
}
|
||||||
|
return ids, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIssueCompletions fetches issues matching the toComplete string for shell completion.
|
||||||
|
func GetIssueCompletions(ctx context.Context, toComplete string) ([]models.Issue, cobra.ShellCompDirective) {
|
||||||
|
if svc == nil {
|
||||||
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
|
||||||
|
issues, err := svc.Beads.AllIssues(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
|
||||||
|
var completions []models.Issue
|
||||||
|
for _, issue := range issues {
|
||||||
|
if strings.HasPrefix(issue.ID, toComplete) {
|
||||||
|
completions = append(completions, issue)
|
||||||
|
} else if strings.HasPrefix(issue.Title, toComplete) {
|
||||||
|
completions = append(completions, issue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return completions, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
@@ -5,90 +5,114 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
"github.com/charmbracelet/huh"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// createFlags holds the flag values for the create command
|
||||||
createDescription string
|
var createFlags Flags
|
||||||
createStatus string
|
|
||||||
createType string
|
const (
|
||||||
createPriority int
|
createCmdExample = `pm create New issue -d "Description" -s open -t task -p 3
|
||||||
|
pm create Fix bug --desc "Bug description" --status in_progress --type bug --priority 5`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// createCmd represents the create command, which allows users to create a new issue with specified details.
|
||||||
var createCmd = &cobra.Command{
|
var createCmd = &cobra.Command{
|
||||||
Use: "create [title]",
|
Use: "create [title]",
|
||||||
Short: "Create a new issue",
|
Short: "Create a new issue",
|
||||||
Long: `Create a new issue with the specified details.`,
|
Long: `Create a new issue with the specified details.`,
|
||||||
Example: `pm create New issue -d "Description" -s open -t task -p 3
|
Example: createCmdExample,
|
||||||
pm create Fix bug --desc "Bug description" --status in_progress --type bug --priority 5`,
|
|
||||||
RunE: runCreateCmd,
|
Args: cobra.MinimumNArgs(0),
|
||||||
Aliases: []string{"add"},
|
Aliases: []string{"add"},
|
||||||
Args: cobra.MinimumNArgs(1),
|
RunE: runCreateCmd,
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
createCmd.Flags().StringVarP(&createDescription, "desc", "d", "", "Issue description")
|
|
||||||
createCmd.Flags().StringVarP(&createStatus, "status", "s", "open", "Issue status(open, closed, in_progress)")
|
|
||||||
createCmd.Flags().StringVarP(&createType, "type", "t", "task", "Issue type(bug, feature, task)")
|
|
||||||
createCmd.Flags().IntVarP(&createPriority, "priority", "p", 0, "Issue priority(0-5)")
|
|
||||||
|
|
||||||
createCmd.RegisterFlagCompletionFunc("type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
||||||
return []string{"bug", "feature", "task"}, cobra.ShellCompDirectiveDefault
|
|
||||||
})
|
|
||||||
|
|
||||||
createCmd.RegisterFlagCompletionFunc("status", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
||||||
return []string{"open", "closed", "in_progress"}, cobra.ShellCompDirectiveDefault
|
|
||||||
})
|
|
||||||
|
|
||||||
createCmd.RegisterFlagCompletionFunc("priority", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
||||||
return []string{"0", "1", "2", "3", "4", "5"}, cobra.ShellCompDirectiveDefault
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runCreateCmd executes the create command logic,
|
||||||
func runCreateCmd(cmd *cobra.Command, args []string) error {
|
func runCreateCmd(cmd *cobra.Command, args []string) error {
|
||||||
createTitle := strings.Join(args, " ")
|
createFlags.title = strings.Join(args, " ")
|
||||||
|
|
||||||
if createTitle == "" {
|
// Run interactive if flag is set
|
||||||
|
if createFlags.interactive {
|
||||||
|
if err := runCreateInteractive(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if createFlags.title == "" {
|
||||||
return fmt.Errorf("issue title cannot be empty")
|
return fmt.Errorf("issue title cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
issue := &models.Issue{
|
issue := &models.Issue{
|
||||||
Title: createTitle,
|
Title: createFlags.title,
|
||||||
Description: createDescription,
|
Description: createFlags.description,
|
||||||
Status: models.Status(createStatus),
|
Status: models.Status(createFlags.status),
|
||||||
IssueType: models.IssueType(createType),
|
IssueType: models.IssueType(createFlags.issueType),
|
||||||
Priority: createPriority,
|
Priority: createFlags.priority,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the issue using the service layer.
|
||||||
err := svc.Beads.CreateIssue(cmd.Context(), issue, "test_actor")
|
err := svc.Beads.CreateIssue(cmd.Context(), issue, "test_actor")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating issue: %w", err)
|
return fmt.Errorf("error creating issue: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
str := fmt.Sprintf("Created issue with ID: %s\n", issue.ID)
|
// Display the created issue details to the user.
|
||||||
|
cmd.Printf("Created issue:\n%s", models.IssueString(*issue))
|
||||||
if issue.Title != "" {
|
|
||||||
str += fmt.Sprintf("Title: %s\n", issue.Title)
|
|
||||||
}
|
|
||||||
|
|
||||||
if issue.Description != "" {
|
|
||||||
str += fmt.Sprintf("Description: %s\n", issue.Description)
|
|
||||||
}
|
|
||||||
|
|
||||||
if issue.Status != "" {
|
|
||||||
str += fmt.Sprintf("Status: %s\n", issue.Status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if issue.IssueType != "" {
|
|
||||||
str += fmt.Sprintf("Type: %s\n", issue.IssueType)
|
|
||||||
}
|
|
||||||
|
|
||||||
if issue.Priority != 0 {
|
|
||||||
str += fmt.Sprintf("Priority: %d\n", issue.Priority)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Print(str)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runCreateInteractive runs the interactive mode for creating issues,
|
||||||
|
// allowing users to input issue details through a form.
|
||||||
|
func runCreateInteractive() error {
|
||||||
|
form := huh.NewForm(
|
||||||
|
|
||||||
|
huh.NewGroup(
|
||||||
|
huh.NewInput().Value(&createFlags.title).Title("Title"),
|
||||||
|
huh.NewText().Value(&createFlags.description).Title("Description")),
|
||||||
|
|
||||||
|
huh.NewGroup(
|
||||||
|
huh.NewSelect[string]().Title("Status").
|
||||||
|
Options(
|
||||||
|
huh.NewOption("Open", "open"),
|
||||||
|
huh.NewOption("Closed", "closed"),
|
||||||
|
huh.NewOption("In Progress", "in_progress"),
|
||||||
|
).Value(&createFlags.status),
|
||||||
|
|
||||||
|
huh.NewSelect[string]().Title("Type").
|
||||||
|
Options(
|
||||||
|
huh.NewOption("Bug", "bug"),
|
||||||
|
huh.NewOption("Feature", "feature"),
|
||||||
|
huh.NewOption("Task", "task"),
|
||||||
|
).Value(&createFlags.issueType),
|
||||||
|
|
||||||
|
huh.NewSelect[int]().Title("Priority").
|
||||||
|
Options(
|
||||||
|
huh.NewOption("0", 0),
|
||||||
|
huh.NewOption("1", 1),
|
||||||
|
huh.NewOption("2", 2),
|
||||||
|
huh.NewOption("3", 3),
|
||||||
|
huh.NewOption("4", 4),
|
||||||
|
).Value(&createFlags.priority),
|
||||||
|
)).WithTheme(huh.ThemeBase16())
|
||||||
|
|
||||||
|
return form.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// init function to set up the create command and its flags.
|
||||||
|
func init() {
|
||||||
|
createCmd.Flags().BoolVarP(&createFlags.interactive, "interactive", "i", false, "Create issue interactively")
|
||||||
|
createCmd.Flags().StringVarP(&createFlags.description, "desc", "d", "", "Issue description")
|
||||||
|
createCmd.Flags().StringVarP(&createFlags.status, "status", "s", "open", "Issue status(open, closed, in_progress)")
|
||||||
|
createCmd.Flags().StringVarP(&createFlags.issueType, "type", "t", "task", "Issue type(bug, feature, task)")
|
||||||
|
createCmd.Flags().IntVarP(&createFlags.priority, "priority", "p", 0, "Issue priority(0-4)")
|
||||||
|
|
||||||
|
createCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||||
|
createCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||||
|
createCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||||
|
|
||||||
|
rootCmd.AddCommand(createCmd)
|
||||||
|
}
|
||||||
|
|||||||
129
pkg/cli/commands/delete.go
Normal file
129
pkg/cli/commands/delete.go
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
"github.com/charmbracelet/huh"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Variables for delete command flag.
|
||||||
|
var (
|
||||||
|
confirmDelete bool
|
||||||
|
deleteIDs []string
|
||||||
|
deleteInteractive bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// deleteCmd represents the delete command.
|
||||||
|
var deleteCmd = &cobra.Command{
|
||||||
|
Use: "delete [id]",
|
||||||
|
Short: "Delete an existing issue",
|
||||||
|
Long: `Delete an existing issue by its ID.`,
|
||||||
|
Example: `pm delete pm-abc`,
|
||||||
|
|
||||||
|
ValidArgsFunction: completeIssues,
|
||||||
|
|
||||||
|
Aliases: []string{"del", "remove", "rm"},
|
||||||
|
RunE: runDeleteCmd,
|
||||||
|
}
|
||||||
|
|
||||||
|
// runDeleteCmd executes the delete command logic,
|
||||||
|
// which deletes an issue by its ID after confirming with the user.
|
||||||
|
func runDeleteCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
deleteID := strings.Join(args, " ")
|
||||||
|
|
||||||
|
if deleteInteractive {
|
||||||
|
if err := runDeleteInteractive(cmd.Context()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if deleteID == "" {
|
||||||
|
return fmt.Errorf("issue ID cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the issue to ensure it exists before deletion.
|
||||||
|
issue, err := svc.Beads.GetIssue(cmd.Context(), deleteID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error fetching issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue == nil {
|
||||||
|
return fmt.Errorf("issue with ID %s not found", deleteID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prompt for confirmation if not already confirmed via flag.
|
||||||
|
if !cmd.Flags().Changed("yes") {
|
||||||
|
huh.NewConfirm().Value(&confirmDelete).
|
||||||
|
Title("You want to delete this issue?").
|
||||||
|
Inline(true).WithTheme(huh.ThemeBase()).Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// If user did not confirm, cancel deletion.
|
||||||
|
if !confirmDelete {
|
||||||
|
cmd.Println("Deletion cancelled.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the issue.
|
||||||
|
err = svc.Beads.DeleteIssue(cmd.Context(), deleteID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error deleting issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Println("Deleted issue with ID:", deleteID)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// runDeleteInteractive runs the interactive mode for deleting issues,
|
||||||
|
// allowing users to select multiple issues for deletion.
|
||||||
|
func runDeleteInteractive(ctx context.Context) error {
|
||||||
|
options := []huh.Option[string]{}
|
||||||
|
|
||||||
|
issues, err := svc.Beads.SearchIssues(ctx, "", models.IssueFilter{})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error fetching issues: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, issue := range issues {
|
||||||
|
desc := fmt.Sprintf("%s: %s", issue.ID, issue.Title)
|
||||||
|
options = append(options, huh.NewOption(desc, issue.ID))
|
||||||
|
}
|
||||||
|
|
||||||
|
form := huh.NewForm(
|
||||||
|
huh.NewGroup(
|
||||||
|
huh.NewMultiSelect[string]().
|
||||||
|
Options(options...).Value(&deleteIDs).
|
||||||
|
Title("Select issues to delete"))).WithTheme(huh.ThemeBase())
|
||||||
|
|
||||||
|
if err := form.Run(); err != nil {
|
||||||
|
return fmt.Errorf("error running interactive form: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(deleteIDs) == 0 {
|
||||||
|
return fmt.Errorf("no issues selected for deletion")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, id := range deleteIDs {
|
||||||
|
err := svc.Beads.DeleteIssue(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error deleting issue with ID %s: %w", id, err)
|
||||||
|
}
|
||||||
|
fmt.Printf("Deleted issue with ID: %s\n", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// init function to set up the delete command and its flags.
|
||||||
|
func init() {
|
||||||
|
deleteCmd.Flags().BoolVarP(&deleteInteractive, "interactive", "i", false, "Delete issues interactively")
|
||||||
|
deleteCmd.Flags().BoolVarP(&confirmDelete, "yes", "y", true, "Confirm deletion without prompt")
|
||||||
|
|
||||||
|
rootCmd.AddCommand(deleteCmd)
|
||||||
|
}
|
||||||
@@ -7,85 +7,79 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// Variables for get-issues command flags.
|
||||||
titleFlag string
|
var listFlags Flags
|
||||||
descriptionFlag string
|
|
||||||
statusFlag string
|
|
||||||
typeFlag string
|
|
||||||
priorityFlag int
|
|
||||||
limit int = 25
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
lsExamples = `pm ls [id|title|description]
|
lsExamples = `pm list [id|title|description]
|
||||||
pm ls --status open --type bug
|
pm list --status open --type bug
|
||||||
pm ls --title "New feature" --desc "feature description"
|
pm list --title "New feature" --desc "feature description"
|
||||||
pm ls -p 1 -l 10`
|
pm list -p 1 -l 10`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getIssuesCmd represents the get issues command.
|
||||||
var getIssuesCmd = &cobra.Command{
|
var getIssuesCmd = &cobra.Command{
|
||||||
Use: "ls [search query]",
|
Use: "list [search query]",
|
||||||
Short: "List all issues",
|
Short: "List all issues",
|
||||||
Long: `List all issues in the project management system.`,
|
Long: `List all issues in the project management system.`,
|
||||||
Aliases: []string{"list", "search"},
|
|
||||||
Example: lsExamples,
|
Example: lsExamples,
|
||||||
|
|
||||||
|
Aliases: []string{"ls", "search"},
|
||||||
Args: cobra.MinimumNArgs(0),
|
Args: cobra.MinimumNArgs(0),
|
||||||
RunE: runGetIssuesCmd,
|
RunE: runGetIssuesCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runGetIssuesCmd executes the get issues command logic,
|
||||||
|
// which retrieves and displays a list of issues based on the provided search query and filters.
|
||||||
func runGetIssuesCmd(cmd *cobra.Command, args []string) error {
|
func runGetIssuesCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
queryArg := strings.Join(args, " ")
|
queryArg := strings.Join(args, " ")
|
||||||
|
|
||||||
filter := models.IssueFilter{
|
filter := models.IssueFilter{
|
||||||
TitleSearch: titleFlag,
|
TitleSearch: listFlags.title,
|
||||||
DescriptionContains: descriptionFlag,
|
DescriptionContains: listFlags.description,
|
||||||
Limit: limit,
|
Limit: listFlags.limit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only set filter fields if the corresponding flags
|
||||||
|
// were explicitly provided by the user.
|
||||||
if cmd.Flags().Changed("status") {
|
if cmd.Flags().Changed("status") {
|
||||||
s := models.Status(statusFlag)
|
s := models.Status(listFlags.status)
|
||||||
filter.Status = &s
|
filter.Status = &s
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("type") {
|
if cmd.Flags().Changed("type") {
|
||||||
t := models.IssueType(typeFlag)
|
t := models.IssueType(listFlags.issueType)
|
||||||
filter.IssueType = &t
|
filter.IssueType = &t
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("priority") {
|
if cmd.Flags().Changed("priority") {
|
||||||
filter.Priority = &priorityFlag
|
filter.Priority = &listFlags.priority
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch issues based on the search query and filters.
|
||||||
issuesPtr, err := svc.Beads.SearchIssues(cmd.Context(), queryArg, filter)
|
issuesPtr, err := svc.Beads.SearchIssues(cmd.Context(), queryArg, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the returned issue pointers to issue values and print them.
|
||||||
issues := models.IssuesPtrToIssues(issuesPtr)
|
issues := models.IssuesPtrToIssues(issuesPtr)
|
||||||
|
|
||||||
models.PrintIssues(issues)
|
models.PrintIssues(issues)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init function to set up the get issues command and its flags.
|
||||||
func init() {
|
func init() {
|
||||||
getIssuesCmd.Flags().StringVar(&titleFlag, "title", "", "Filter issues by title")
|
getIssuesCmd.Flags().StringVar(&listFlags.title, "title", "", "Filter issues by title")
|
||||||
getIssuesCmd.Flags().StringVarP(&descriptionFlag, "desc", "d", "", "Filter issues by description")
|
getIssuesCmd.Flags().StringVarP(&listFlags.description, "desc", "d", "", "Filter issues by description")
|
||||||
getIssuesCmd.Flags().StringVarP(&statusFlag, "status", "s", "", "Filter issues by status (open, closed, in_progress)")
|
getIssuesCmd.Flags().StringVarP(&listFlags.status, "status", "s", "", "Filter issues by status (open, closed, in_progress)")
|
||||||
getIssuesCmd.Flags().StringVarP(&typeFlag, "type", "t", "", "Filter issues by type (bug, feature, task)")
|
getIssuesCmd.Flags().StringVarP(&listFlags.issueType, "type", "t", "", "Filter issues by type (bug, feature, task)")
|
||||||
getIssuesCmd.Flags().IntVarP(&priorityFlag, "priority", "p", 0, "Filter issues by priority (0-5)")
|
getIssuesCmd.Flags().IntVarP(&listFlags.priority, "priority", "p", 0, "Filter issues by priority (0-4)")
|
||||||
getIssuesCmd.Flags().IntVarP(&limit, "limit", "l", 25, "Limit the number of issues returned")
|
|
||||||
|
|
||||||
getIssuesCmd.RegisterFlagCompletionFunc("status", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
getIssuesCmd.Flags().IntVarP(&listFlags.limit, "limit", "l", 25, "Limit the number of issues returned")
|
||||||
return []string{"open", "closed", "in_progress"}, cobra.ShellCompDirectiveDefault
|
|
||||||
})
|
|
||||||
|
|
||||||
getIssuesCmd.RegisterFlagCompletionFunc("type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
getIssuesCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||||
return []string{"bug", "feature", "task"}, cobra.ShellCompDirectiveDefault
|
getIssuesCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||||
})
|
getIssuesCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||||
|
|
||||||
getIssuesCmd.RegisterFlagCompletionFunc("priority", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
||||||
return []string{"0", "1", "2", "3", "4", "5"}, cobra.ShellCompDirectiveDefault
|
|
||||||
})
|
|
||||||
|
|
||||||
rootCmd.AddCommand(getIssuesCmd)
|
rootCmd.AddCommand(getIssuesCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +1,47 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getIssueCmd represents the get issue command.
|
||||||
var getIssueCmd = &cobra.Command{
|
var getIssueCmd = &cobra.Command{
|
||||||
Use: "describe [issue ID]",
|
Use: "describe [issue ID]",
|
||||||
Aliases: []string{"get", "read"},
|
Short: "Get issue details",
|
||||||
Short: "Get issue details",
|
Long: `Get issue details by ID`,
|
||||||
Long: `Get issue details by ID`,
|
|
||||||
RunE: runGetCmd,
|
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
ValidArgsFunction: completeIssues,
|
ValidArgsFunction: completeIssues,
|
||||||
|
|
||||||
|
Aliases: []string{"get", "read"},
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
RunE: runGetCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runGetCmd executes the get issue command logic,
|
||||||
|
// which retrieves and displays issue details by its ID.
|
||||||
func runGetCmd(cmd *cobra.Command, args []string) error {
|
func runGetCmd(cmd *cobra.Command, args []string) error {
|
||||||
issueID := args[0]
|
issueID := args[0]
|
||||||
|
|
||||||
issue, err := svc.Beads.GetIssue(cmd.Context(), issueID)
|
// Fetch the issue details using the service layer.
|
||||||
|
issuePtr, err := svc.Beads.GetIssue(cmd.Context(), issueID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if issue == nil {
|
// If the issue is not found, inform the user.
|
||||||
cmd.Printf("Issue with ID '%s' not found\n", issueID)
|
if issuePtr == nil {
|
||||||
|
cmd.Printf("Issue with ID %s not found\n", issueID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Title: %s\n", issue.Title)
|
// Display the issue details to the user.
|
||||||
cmd.Printf("Description: %s\n", issue.Description)
|
cmd.Println(models.IssueString(*issuePtr))
|
||||||
cmd.Printf("Status: %s\n", issue.Status)
|
|
||||||
cmd.Printf("Type: %s\n", issue.IssueType)
|
|
||||||
cmd.Printf("Priority: %d\n", issue.Priority)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init function to set up the get issue command.
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(getIssueCmd)
|
rootCmd.AddCommand(getIssueCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeIssues(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
||||||
if svc == nil {
|
|
||||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
}
|
|
||||||
|
|
||||||
issues, err := svc.Beads.AllIssues(cmd.Context())
|
|
||||||
if err != nil {
|
|
||||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
}
|
|
||||||
|
|
||||||
var completions []string
|
|
||||||
for _, issue := range issues {
|
|
||||||
|
|
||||||
if strings.HasPrefix(issue.ID, toComplete) {
|
|
||||||
completions = append(completions, issue.ID)
|
|
||||||
} else if strings.HasPrefix(issue.Title, toComplete) {
|
|
||||||
completions = append(completions, issue.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return completions, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,27 +1,73 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||||
|
"github.com/charmbracelet/fang"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// svc is a global variable that holds beads, config and stats services.
|
||||||
|
// Must be called before executing any commands to ensure services are available.
|
||||||
var svc *service.Services
|
var svc *service.Services
|
||||||
|
|
||||||
|
// Flags struct to hold command-line flag values for issues.
|
||||||
|
type Flags struct {
|
||||||
|
interactive bool
|
||||||
|
limit int
|
||||||
|
|
||||||
|
title string
|
||||||
|
description string
|
||||||
|
status string
|
||||||
|
issueType string
|
||||||
|
priority int
|
||||||
|
}
|
||||||
|
|
||||||
|
// rootCmd is the base command for the CLI application.
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Short: "Project Management CLI",
|
Short: "Project Management CLI",
|
||||||
Long: `Project Management CLI for managing issues and tasks.`,
|
Long: `Project Management CLI for managing issues and tasks.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute(services *service.Services) error {
|
// SetServices sets the global services variable for use in command execution.
|
||||||
|
// Must be called before executing any commands to ensure services are available.
|
||||||
|
func SetServices(services *service.Services) {
|
||||||
svc = services
|
svc = services
|
||||||
rootCmd.Use = svc.Config.RootCmd
|
rootCmd.Use = svc.Config.RootCmd
|
||||||
return rootCmd.Execute()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
// Execute executes the root command using the fang library.
|
||||||
rootCmd.AddCommand(createCmd)
|
func Execute() error {
|
||||||
|
return fang.Execute(context.Background(), rootCmd,
|
||||||
|
fang.WithColorSchemeFunc(fang.AnsiColorScheme))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteArgs executes the command with the given arguments using the fang library.
|
||||||
|
func ExecuteArgs(args []string) error {
|
||||||
|
rootCmd.SetArgs(args)
|
||||||
|
return fang.Execute(context.Background(), rootCmd,
|
||||||
|
fang.WithColorSchemeFunc(fang.AnsiColorScheme))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteArgsString executes the command with the given arguments and returns the output as a string.
|
||||||
|
// This is useful for testing command outputs and used in the REPL
|
||||||
|
func ExecuteArgsString(args []string) (string, error) {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
|
rootCmd.SetOut(buf)
|
||||||
|
rootCmd.SetErr(buf)
|
||||||
|
rootCmd.SetArgs(args)
|
||||||
|
|
||||||
|
err := rootCmd.Execute()
|
||||||
|
|
||||||
|
return buf.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// init function to set up the command hierarchy and options.
|
||||||
|
func init() {
|
||||||
rootCmd.CompletionOptions.DisableDefaultCmd = false
|
rootCmd.CompletionOptions.DisableDefaultCmd = false
|
||||||
rootCmd.AddGroup(&cobra.Group{ID: "help", Title: "Helping Commands"})
|
rootCmd.AddGroup(&cobra.Group{ID: "help", Title: "Helping Commands"})
|
||||||
rootCmd.SetCompletionCommandGroupID("help")
|
rootCmd.SetCompletionCommandGroupID("help")
|
||||||
|
|||||||
100
pkg/cli/commands/update.go
Normal file
100
pkg/cli/commands/update.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var updateFlags Flags
|
||||||
|
|
||||||
|
var updateCmd = &cobra.Command{
|
||||||
|
Use: "update [issue ID]",
|
||||||
|
Short: "Update an existing issue",
|
||||||
|
Long: `Update an existing issue by its ID with the specified details.`,
|
||||||
|
Example: `pm update pm-001 --title "New title" -d "Description" -s in_progress --type task -p 3`,
|
||||||
|
RunE: runUpdateCmd,
|
||||||
|
Aliases: []string{"edit"},
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
ValidArgsFunction: completeIssues,
|
||||||
|
}
|
||||||
|
|
||||||
|
func runUpdateCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
issueID := args[0]
|
||||||
|
|
||||||
|
issue, err := svc.Beads.GetIssue(cmd.Context(), issueID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue == nil {
|
||||||
|
return fmt.Errorf("issue with ID %s not found", issueID)
|
||||||
|
}
|
||||||
|
|
||||||
|
updates, err := getUpdateValues(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting update values: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = svc.Beads.UpdateIssue(cmd.Context(), issueID, updates, "test_actor")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error updating issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedIssue, err := svc.Beads.GetIssue(cmd.Context(), issueID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting updated issue: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Updated issue to:\n%s", models.IssueString(*updatedIssue))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
updateCmd.Flags().StringVar(&updateFlags.title, "title", "", "New issue title")
|
||||||
|
updateCmd.Flags().StringVarP(&updateFlags.description, "desc", "d", "", "New issue description")
|
||||||
|
updateCmd.Flags().StringVarP(&updateFlags.status, "status", "s", "", "New issue status(open, closed, in_progress)")
|
||||||
|
updateCmd.Flags().StringVarP(&updateFlags.issueType, "type", "t", "", "New issue type(bug, feature, task)")
|
||||||
|
updateCmd.Flags().IntVarP(&updateFlags.priority, "priority", "p", 0, "New issue priority(0-5)")
|
||||||
|
|
||||||
|
updateCmd.RegisterFlagCompletionFunc("type", completionFunc(typeOptions))
|
||||||
|
updateCmd.RegisterFlagCompletionFunc("status", completionFunc(statusOptions))
|
||||||
|
updateCmd.RegisterFlagCompletionFunc("priority", completionFunc(priorityRange))
|
||||||
|
|
||||||
|
rootCmd.AddCommand(updateCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getUpdateValues(cmd *cobra.Command) (map[string]interface{}, error) {
|
||||||
|
updates := make(map[string]interface{})
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("title") {
|
||||||
|
if updateFlags.title == "" {
|
||||||
|
return updates, fmt.Errorf("issue title cannot be empty")
|
||||||
|
}
|
||||||
|
updates["title"] = updateFlags.title
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("desc") {
|
||||||
|
updates["description"] = updateFlags.description
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("status") {
|
||||||
|
updates["status"] = updateFlags.status
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("type") {
|
||||||
|
updates["issue_type"] = updateFlags.issueType
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("priority") {
|
||||||
|
updates["priority"] = updateFlags.priority
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(updates) == 0 {
|
||||||
|
return updates, fmt.Errorf("no updates specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
return updates, nil
|
||||||
|
}
|
||||||
36
pkg/cli/repl/completer.go
Normal file
36
pkg/cli/repl/completer.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package repl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/c-bata/go-prompt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// completer provides suggestions for the REPL input based on the current input text.
|
||||||
|
func completer(d prompt.Document) []prompt.Suggest {
|
||||||
|
text := d.TextBeforeCursor() // Gets the text before the cursor as a string.
|
||||||
|
words := strings.Fields(text) // Split the string into words as []string.
|
||||||
|
|
||||||
|
// If there are no words, return no suggestions.
|
||||||
|
if len(words) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the first word is not "pm", only provide root-level suggestions.
|
||||||
|
if words[0] != "pm" {
|
||||||
|
return filterByPrefix(rootSuggestions, words[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the first word is "pm", provide command and flag suggestions based on the context.
|
||||||
|
pmWords := words[1:]
|
||||||
|
if len(words) == 1 || (len(pmWords) == 1 && !strings.HasSuffix(text, " ")) {
|
||||||
|
return commandSuggestions(pmWords)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the last word starts with a "-", provide flag suggestions for the current command.
|
||||||
|
if len(pmWords) >= 1 {
|
||||||
|
return flagSuggestions(pmWords[0], pmWords, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
55
pkg/cli/repl/executor.go
Normal file
55
pkg/cli/repl/executor.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package repl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
// execute processes the input command and returns the output
|
||||||
|
// or an error if it occurs. It handles what type of command is being executed,
|
||||||
|
// whether it's a PM command or a shell command, and routes it accordingly.
|
||||||
|
func execute(input string) (string, error) {
|
||||||
|
if input == "" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if input == "help" {
|
||||||
|
return ReplHelp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if input == "title" {
|
||||||
|
return ReplTitle, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if after, ok := strings.CutPrefix(input, "pm"); ok {
|
||||||
|
return executePMCommand(after)
|
||||||
|
}
|
||||||
|
return executeShellCommand(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
// executeShellCommand executes a shell command
|
||||||
|
// and returns its output or an error if it occurs.
|
||||||
|
func executeShellCommand(input string) (string, error) {
|
||||||
|
parts := strings.Fields(input)
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command(parts[0], parts[1:]...)
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
return string(output), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// executePMCommand executes a PM command using the commands package
|
||||||
|
// and returns its output or an error if it occurs.
|
||||||
|
func executePMCommand(input string) (string, error) {
|
||||||
|
parts := strings.Fields(input)
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := commands.ExecuteArgsString(parts)
|
||||||
|
return output, err
|
||||||
|
}
|
||||||
22
pkg/cli/repl/options.go
Normal file
22
pkg/cli/repl/options.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package repl
|
||||||
|
|
||||||
|
import "github.com/c-bata/go-prompt"
|
||||||
|
|
||||||
|
const PromptPrefix = "> "
|
||||||
|
const OptionMaxSuggestions = 5
|
||||||
|
|
||||||
|
// promptOptions returns a slice of prompt.Option
|
||||||
|
// to configure the behavior and appearance of the REPL prompt.
|
||||||
|
func promptOptions(history []string) []prompt.Option {
|
||||||
|
return []prompt.Option{
|
||||||
|
prompt.OptionPrefixTextColor(prompt.Cyan),
|
||||||
|
prompt.OptionMaxSuggestion(OptionMaxSuggestions),
|
||||||
|
prompt.OptionSuggestionBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionSelectedSuggestionBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionDescriptionBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionSelectedDescriptionBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionPreviewSuggestionBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionScrollbarBGColor(prompt.DefaultColor),
|
||||||
|
prompt.OptionHistory(history),
|
||||||
|
}
|
||||||
|
}
|
||||||
78
pkg/cli/repl/repl.go
Normal file
78
pkg/cli/repl/repl.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// Package repl implements the Read-Eval-Print Loop (REPL) for the PM CLI.
|
||||||
|
package repl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/styles"
|
||||||
|
"github.com/c-bata/go-prompt"
|
||||||
|
"golang.org/x/term"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReplHelp = `Type 'pm help' for available PM commands.
|
||||||
|
You can also run shell commands directly. Type 'exit' or 'quit' to leave.`
|
||||||
|
|
||||||
|
ReplTitle = "Welcome to Project Management CLI! " + ReplHelp
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunREPL starts the interactive Read-Eval-Print Loop for the PM CLI.
|
||||||
|
func RunREPL(ctx context.Context, config cli.CLIConfig) error {
|
||||||
|
// Set terminal to raw mode to capture input properly in the REPL.
|
||||||
|
// This allows us to handle input character by character and provide a better user experience.
|
||||||
|
// We also ensure that the terminal state is restored when the REPL exits, even if an error occurs.
|
||||||
|
oldState, err := term.GetState(int(os.Stdin.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get terminal state: %w", err)
|
||||||
|
}
|
||||||
|
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||||
|
|
||||||
|
// Initialize services for beads, config and stats.
|
||||||
|
svc, cleanup, err := service.NewServices(ctx, config)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to initialize services: %w", err)
|
||||||
|
}
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
// Make sure to set services, to ensure they are available.
|
||||||
|
commands.SetServices(svc)
|
||||||
|
|
||||||
|
fmt.Println(styles.TitleStyle.Render(ReplTitle)) // Print REPL title.
|
||||||
|
|
||||||
|
// history keeps track of command history.
|
||||||
|
// This enables navigating through previous commands.
|
||||||
|
var history []string
|
||||||
|
|
||||||
|
// Start the REPL loop, which continues until the user types "exit" or "quit".
|
||||||
|
for {
|
||||||
|
// Prompt the user for input, and provide suggestions.
|
||||||
|
input := prompt.Input(
|
||||||
|
PromptPrefix,
|
||||||
|
completer,
|
||||||
|
promptOptions(history)...,
|
||||||
|
)
|
||||||
|
|
||||||
|
// Trim whitespace from the input to ensure consistent command processing.
|
||||||
|
input = strings.TrimSpace(input)
|
||||||
|
|
||||||
|
// If the user types "exit" or "quit", break the loop and exit the REPL.
|
||||||
|
if input == "exit" || input == "quit" {
|
||||||
|
fmt.Println("Goodbye!")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the input to the history for future navigation.
|
||||||
|
history = append(history, input)
|
||||||
|
|
||||||
|
output, _ := execute(input) // Ignore errors for now, gives better ux
|
||||||
|
fmt.Println(styles.CommandStyle.Render(output)) // Print the output of the command in a styled format.
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
201
pkg/cli/repl/suggestions.go
Normal file
201
pkg/cli/repl/suggestions.go
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
package repl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
|
||||||
|
"github.com/c-bata/go-prompt"
|
||||||
|
"github.com/muesli/reflow/truncate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// rootSuggestions is a list of prompt suggestions for root-level commands.
|
||||||
|
var rootSuggestions = []prompt.Suggest{
|
||||||
|
{Text: "pm", Description: "Project Management System"},
|
||||||
|
{Text: "exit", Description: "Exit pm CLI"},
|
||||||
|
{Text: "help", Description: "Show help information"},
|
||||||
|
{Text: "title", Description: "Print the welcome title"},
|
||||||
|
{Text: "git", Description: "Version control system"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// commandSuggestions is a list of prompt suggestions for PM commands.
|
||||||
|
var baseSuggestions = []prompt.Suggest{
|
||||||
|
{Text: "help", Description: "Show help information"},
|
||||||
|
{Text: "delete", Description: "Delete an issue by ID"},
|
||||||
|
{Text: "close", Description: "Close an issue by ID"},
|
||||||
|
{Text: "create", Description: "Create a new issue with title"},
|
||||||
|
{Text: "update", Description: "Update an existing issue by ID"},
|
||||||
|
{Text: "describe", Description: "Get issue details by ID"},
|
||||||
|
{Text: "list", Description: "List all issues"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// createFlags is a list of prompt suggestions for the create command flags.
|
||||||
|
var createFlags = []prompt.Suggest{
|
||||||
|
{Text: "--interactive", Description: "Create issue interactively"},
|
||||||
|
{Text: "--desc", Description: "Issue description"},
|
||||||
|
{Text: "--status", Description: "Issue status (open, closed, in_progress)"},
|
||||||
|
{Text: "--type", Description: "Issue type (bug, feature, task)"},
|
||||||
|
{Text: "--priority", Description: "Issue priority (0-5)"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateFlags is a list of prompt suggestions for the update command flags.
|
||||||
|
var updateFlags = []prompt.Suggest{
|
||||||
|
{Text: "--title", Description: "New issue title"},
|
||||||
|
{Text: "--desc", Description: "New issue description"},
|
||||||
|
{Text: "--status", Description: "New issue status (open, closed, in_progress)"},
|
||||||
|
{Text: "--type", Description: "New issue type (bug, feature, task)"},
|
||||||
|
{Text: "--priority", Description: "New issue priority (0-5)"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// listFlags is a list of prompt suggestions for the list command flags.
|
||||||
|
var listFlags = []prompt.Suggest{
|
||||||
|
{Text: "--title", Description: "Filter by title"},
|
||||||
|
{Text: "--desc", Description: "Filter by description"},
|
||||||
|
{Text: "--status", Description: "Filter by status (open, closed, in_progress)"},
|
||||||
|
{Text: "--type", Description: "Filter by type (bug, feature, task)"},
|
||||||
|
{Text: "--priority", Description: "Filter by priority (0-5)"},
|
||||||
|
{Text: "--limit", Description: "Limit number of results"},
|
||||||
|
}
|
||||||
|
|
||||||
|
var deleteFlags = []prompt.Suggest{
|
||||||
|
{Text: "--yes", Description: "Confirm deletion without prompt"},
|
||||||
|
{Text: "--interactive", Description: "Select issues to delete interactively"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// statusValues is a list of prompt suggestions for status types
|
||||||
|
var statusValues = []prompt.Suggest{
|
||||||
|
{Text: "open", Description: "Open status"},
|
||||||
|
{Text: "closed", Description: "Closed status"},
|
||||||
|
{Text: "in_progress", Description: "In progress status"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// typeValues is a list of prompt suggestions for issue types
|
||||||
|
var typeValues = []prompt.Suggest{
|
||||||
|
{Text: "bug", Description: "Bug issue type"},
|
||||||
|
{Text: "feature", Description: "Feature issue type"},
|
||||||
|
{Text: "task", Description: "Task issue type"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// priorityValues is a list of prompt suggestions for issue priority levels
|
||||||
|
var priorityValues = []prompt.Suggest{
|
||||||
|
{Text: "0", Description: "Lowest priority"},
|
||||||
|
{Text: "1", Description: "Low priority"},
|
||||||
|
{Text: "2", Description: "Medium-low priority"},
|
||||||
|
{Text: "3", Description: "Medium priority"},
|
||||||
|
{Text: "4", Description: "High priority"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// isIDCommand maps command names to a boolean indicating whether they expect an issue ID as an argument.
|
||||||
|
var isIDCommand = map[string]bool{
|
||||||
|
"describe": true,
|
||||||
|
"delete": true,
|
||||||
|
"del": true,
|
||||||
|
"rm": true,
|
||||||
|
"remove": true,
|
||||||
|
"get": true,
|
||||||
|
"read": true,
|
||||||
|
"close": true,
|
||||||
|
"update": true,
|
||||||
|
"edit": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
var commandFlags = map[string][]prompt.Suggest{
|
||||||
|
"create": createFlags,
|
||||||
|
"add": createFlags,
|
||||||
|
"update": updateFlags,
|
||||||
|
"edit": updateFlags,
|
||||||
|
"list": listFlags,
|
||||||
|
"ls": listFlags,
|
||||||
|
"search": listFlags,
|
||||||
|
"delete": deleteFlags,
|
||||||
|
"del": deleteFlags,
|
||||||
|
"rm": deleteFlags,
|
||||||
|
"remove": deleteFlags,
|
||||||
|
}
|
||||||
|
|
||||||
|
// commandSuggestions returns a list of prompt suggestions based on the current input words.
|
||||||
|
func commandSuggestions(words []string) []prompt.Suggest {
|
||||||
|
if len(words) == 0 {
|
||||||
|
return baseSuggestions
|
||||||
|
}
|
||||||
|
return filterByPrefix(baseSuggestions, words[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// flagSuggestions returns a list of prompt suggestions for command flags based on the current input.
|
||||||
|
func flagSuggestions(cmd string, words []string, text string) []prompt.Suggest {
|
||||||
|
lastWord, prevWord := parseWords(words, text)
|
||||||
|
|
||||||
|
if values := getFlagValues(prevWord); values != nil {
|
||||||
|
return filterByPrefix(values, lastWord)
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := commandFlags[cmd]
|
||||||
|
|
||||||
|
if isIDCommand[cmd] {
|
||||||
|
if len(words) < 2 && !strings.HasPrefix(lastWord, "-") {
|
||||||
|
return issueIDSuggestions(lastWord, true)
|
||||||
|
}
|
||||||
|
return filterByPrefix(flags, lastWord)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filterByPrefix(flags, lastWord)
|
||||||
|
}
|
||||||
|
|
||||||
|
// issueIDSuggestions returns a list of prompt suggestions for issue IDs based on the current partial input.
|
||||||
|
func issueIDSuggestions(partial string, hasCommand bool) []prompt.Suggest {
|
||||||
|
// Only show suggestions if we've typed the command already
|
||||||
|
if !hasCommand {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
issues, _ := commands.GetIssueCompletions(context.Background(), partial)
|
||||||
|
|
||||||
|
var suggestions []prompt.Suggest
|
||||||
|
for _, issue := range issues {
|
||||||
|
suggestions = append(suggestions, prompt.Suggest{
|
||||||
|
Text: issue.ID,
|
||||||
|
Description: truncate.String(issue.Title, 20),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return suggestions
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseWords extracts the last and previous words from the input for flag suggestion logic.
|
||||||
|
func parseWords(words []string, text string) (lastWord, prevWord string) {
|
||||||
|
if len(words) > 0 && !strings.HasSuffix(text, " ") {
|
||||||
|
lastWord = words[len(words)-1]
|
||||||
|
if len(words) >= 2 {
|
||||||
|
prevWord = words[len(words)-2]
|
||||||
|
}
|
||||||
|
} else if len(words) >= 1 {
|
||||||
|
prevWord = words[len(words)-1]
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// getFlagValues returns a list of prompt suggestions for flag values based on the given flag.
|
||||||
|
func getFlagValues(flag string) []prompt.Suggest {
|
||||||
|
switch flag {
|
||||||
|
case "-s", "--status":
|
||||||
|
return statusValues
|
||||||
|
case "-t", "--type":
|
||||||
|
return typeValues
|
||||||
|
case "-p", "--priority":
|
||||||
|
return priorityValues
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// filterByPrefix filters a list of prompt suggestions based on a given prefix.
|
||||||
|
func filterByPrefix(suggestions []prompt.Suggest, prefix string) []prompt.Suggest {
|
||||||
|
if prefix == "" {
|
||||||
|
return suggestions
|
||||||
|
}
|
||||||
|
var filtered []prompt.Suggest
|
||||||
|
for _, s := range suggestions {
|
||||||
|
if strings.HasPrefix(s.Text, prefix) {
|
||||||
|
filtered = append(filtered, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered
|
||||||
|
}
|
||||||
10
pkg/cli/styles/styles.go
Normal file
10
pkg/cli/styles/styles.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// Package styles defines the styling for the CLI output using the lipgloss library.
|
||||||
|
package styles
|
||||||
|
|
||||||
|
import "github.com/charmbracelet/lipgloss"
|
||||||
|
|
||||||
|
var (
|
||||||
|
TitleStyle = lipgloss.NewStyle().Bold(true).Padding(1)
|
||||||
|
|
||||||
|
CommandStyle = lipgloss.NewStyle().Padding(1)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user