refactor to make cli better and simplify the code

This commit is contained in:
Robin Olsen
2026-03-01 20:42:56 +01:00
parent a266ce5464
commit 9612cb9338
32 changed files with 182 additions and 255 deletions

View File

@@ -3,26 +3,29 @@ package main
import (
"context"
"github.com/LazyBachelor/LazyPM/internal/app"
issues "github.com/LazyBachelor/LazyPM/internal/commands/issues"
survey "github.com/LazyBachelor/LazyPM/internal/commands/survey"
"github.com/LazyBachelor/LazyPM/internal/models"
"github.com/LazyBachelor/LazyPM/pkg/cli"
"github.com/charmbracelet/fang"
)
var App *app.App
var RootCmd = issues.RootCmd
func main() {
if err := cli.New(issues.RootCmd).Run(context.Background(), models.BaseConfig); err != nil {
ctx := context.Background()
app, cleanup, err := initializeServices(ctx)
if err != nil {
return
}
defer cleanup()
App = app
survey.SetApp(App)
issues.SetApp(App)
if err := fang.Execute(ctx, RootCmd,
fang.WithColorSchemeFunc(fang.AnsiColorScheme)); err != nil {
return
}
}
func init() {
issues.RootCmd.AddCommand(issues.GetCmd)
issues.RootCmd.AddCommand(issues.ListCmd)
issues.RootCmd.AddCommand(issues.CloseCmd)
issues.RootCmd.AddCommand(issues.CreateCmd)
issues.RootCmd.AddCommand(issues.DeleteCmd)
issues.RootCmd.AddCommand(issues.UpdateCmd)
issues.RootCmd.AddCommand(issues.CommentCmd)
issues.RootCmd.AddCommand(issues.CommentsCmd)
issues.RootCmd.AddCommand(survey.StatusCmd)
}