From c243209aff554bd4dcb99edc9561acf665a7372e Mon Sep 17 00:00:00 2001 From: vb Date: Thu, 5 Feb 2026 14:51:19 +0100 Subject: [PATCH] adding delete command in the file pkg/cli/commands/delete.go --- .beads/issues.jsonl | 3 +++ pkg/cli/commands/delete.go | 47 ++++++++++++++++++++++++++++++++++++++ pkg/cli/commands/root.go | 1 + 3 files changed, 51 insertions(+) create mode 100644 .beads/issues.jsonl create mode 100644 pkg/cli/commands/delete.go diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl new file mode 100644 index 0000000..dc687ff --- /dev/null +++ b/.beads/issues.jsonl @@ -0,0 +1,3 @@ +{"id":"LazyPM-15e","title":"issue1","status":"tombstone","priority":2,"issue_type":"feature","owner":"viljarb@tutanota.com","created_at":"2026-02-05T12:54:47.980567399+01:00","created_by":"vb","updated_at":"2026-02-05T12:54:54.505284343+01:00","deleted_at":"2026-02-05T12:54:54.505284343+01:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"feature"} +{"id":"LazyPM-5dx","title":"gergreerg","description":"rgkjioergioreg","status":"tombstone","priority":2,"issue_type":"feature","owner":"viljarb@tutanota.com","created_at":"2026-02-05T12:59:44.540301146+01:00","created_by":"vb","updated_at":"2026-02-05T14:14:33.565644925+01:00","deleted_at":"2026-02-05T14:14:33.565644925+01:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"feature"} +{"id":"LazyPM-9qt","title":"asdf","description":"asjoidiajsoijodas","status":"tombstone","priority":2,"issue_type":"feature","owner":"viljarb@tutanota.com","created_at":"2026-02-05T12:59:28.40054283+01:00","created_by":"vb","updated_at":"2026-02-05T14:14:28.948203666+01:00","deleted_at":"2026-02-05T14:14:28.948203666+01:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"feature"} diff --git a/pkg/cli/commands/delete.go b/pkg/cli/commands/delete.go new file mode 100644 index 0000000..443bc58 --- /dev/null +++ b/pkg/cli/commands/delete.go @@ -0,0 +1,47 @@ +package commands + +import ( + "fmt" + "strings" + + "github.com/LazyBachelor/LazyPM/internal/models" + + "github.com/spf13/cobra" +) + +var deleteCmd = &cobra.Command{ + Use: "delete [id]", + Short: "Delete existing issue", + Long: `Delete an existing issue by its ID.`, + Example: `pm delete issue_id`, + RunE: runDeleteCmd, + Aliases: []string{"del"}, + Args: cobra.MinimumNArgs(1), +} + +func runDeleteCmd(cmd *cobra.Command, args []string) error { + deleteID := strings.Join(args, " ") + + if deleteID == "" { + return fmt.Errorf("issue title cannot be empty") + } + + issue := &models.Issue{ + ID: deleteID, + } + + err := svc.Beads.DeleteIssue(cmd.Context(), issue.ID) + if err != nil { + return fmt.Errorf("error deleting issue: %w", err) + } + + str := fmt.Sprintf("Deleted issue with ID: %s\n", issue.ID) + + if issue.Title != "" { + str += fmt.Sprintf("Title: %s\n", issue.Title) + } + + fmt.Print(str) + + return nil +} diff --git a/pkg/cli/commands/root.go b/pkg/cli/commands/root.go index ebe772f..75098e3 100644 --- a/pkg/cli/commands/root.go +++ b/pkg/cli/commands/root.go @@ -21,6 +21,7 @@ func Execute(services *service.Services) error { func init() { rootCmd.AddCommand(createCmd) + rootCmd.AddCommand(deleteCmd) rootCmd.CompletionOptions.DisableDefaultCmd = false rootCmd.AddGroup(&cobra.Group{ID: "other", Title: "Helping Commands"}) rootCmd.SetCompletionCommandGroupID("other")