refine architecture

change module name to repo
This commit is contained in:
Robin Olsen
2026-02-02 11:22:20 +01:00
parent 4225d202bb
commit 0dcfe3989d
32 changed files with 822 additions and 114 deletions

25
pkg/cli/cli.go Normal file
View File

@@ -0,0 +1,25 @@
package cli
import (
"github.com/LazyBachelor/LazyPM/internal/service"
"github.com/LazyBachelor/LazyPM/pkg/cli/commands"
"context"
)
type CLIConfig = service.Config
func Run(ctx context.Context, config CLIConfig) error {
svc, cleanup, err := service.NewServices(ctx, config)
if err != nil {
return err
}
defer cleanup()
if err := commands.Execute(svc); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,34 @@
package commands
import (
"github.com/LazyBachelor/LazyPM/internal/models"
"fmt"
"os"
"github.com/spf13/cobra"
)
var createCmd = &cobra.Command{
Use: "create",
Short: "Create a new issue",
Long: `Create a new issue with the specified details.`,
RunE: runCreateCmd,
}
func runCreateCmd(cmd *cobra.Command, args []string) error {
issue := &models.Issue{
Title: "test",
Description: "This is a test issue created by the CLI.",
Status: models.StatusOpen,
IssueType: models.TypeBug,
Priority: 0,
}
err := svc.Beads.CreateIssue(cmd.Context(), issue, "test_actor")
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating issue: %v\n", err)
os.Exit(1)
}
fmt.Printf("Created issue: %s\n", issue.ID)
return nil
}

24
pkg/cli/commands/root.go Normal file
View File

@@ -0,0 +1,24 @@
package commands
import (
"github.com/LazyBachelor/LazyPM/internal/service"
"github.com/spf13/cobra"
)
var svc *service.Services
var rootCmd = &cobra.Command{
Use: "pm",
Short: "Project Management CLI",
Long: `Project Management CLI for managing issues and tasks.`,
}
func Execute(services *service.Services) error {
svc = services
return rootCmd.Execute()
}
func init() {
rootCmd.AddCommand(createCmd)
}