refine architecture
change module name to repo
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads"
|
||||
)
|
||||
|
||||
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 := &beads.Issue{
|
||||
Title: "test",
|
||||
Description: "This is a test issue created by the CLI.",
|
||||
Status: beads.StatusOpen,
|
||||
IssueType: beads.TypeBug,
|
||||
Priority: 0,
|
||||
}
|
||||
|
||||
err := svc.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
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"beadstest/internal/service"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var svc *service.Service
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "pm",
|
||||
Short: "Project Management CLI",
|
||||
Long: `Project Management CLI for managing issues and tasks.`,
|
||||
}
|
||||
|
||||
func Execute(beadsService *service.Service) error {
|
||||
svc = beadsService
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(createCmd)
|
||||
}
|
||||
@@ -1,31 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"beadstest/cmd/cli/commands"
|
||||
"beadstest/internal/service"
|
||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/cli"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/steveyegge/beads"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
config := service.Config{
|
||||
IssuePrefix: "pm",
|
||||
BeadsDBPath: "./.pm/db.db",
|
||||
StatisticsStoragePath: "./.pm/stats.json",
|
||||
}
|
||||
|
||||
store, err := beads.NewSQLiteStorage(ctx, "./db.db")
|
||||
handleError(err)
|
||||
defer store.Close()
|
||||
|
||||
svc, err := service.NewService(ctx, store, "pm")
|
||||
handleError(err)
|
||||
defer svc.Close()
|
||||
|
||||
handleError(commands.Execute(svc))
|
||||
}
|
||||
|
||||
func handleError(err error) {
|
||||
if err != nil {
|
||||
if err := cli.Run(context.Background(), config); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user