Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions skills/linear-cli/references/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ Options:
Commands:

add [issueId] - Add a comment to an issue or reply to a comment
delete <commentId> - Delete a comment
update <commentId> - Update an existing comment
list [issueId] - List comments for an issue
```
Expand All @@ -364,6 +365,22 @@ Options:
-a, --attach <filepath> - Attach a file to the comment (can be used multiple times)
```

##### delete

```
Usage: linear issue comment delete <commentId>
Version: 1.10.0

Description:

Delete a comment

Options:

-h, --help - Show this help.
-w, --workspace <slug> - Target workspace (uses credentials)
```

##### update

```
Expand Down
31 changes: 31 additions & 0 deletions src/commands/issue/issue-comment-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Command } from "@cliffy/command"
import { gql } from "../../__codegen__/gql.ts"
import { getGraphQLClient } from "../../utils/graphql.ts"
import { CliError, handleError } from "../../utils/errors.ts"

export const commentDeleteCommand = new Command()
.name("delete")
.description("Delete a comment")
.arguments("<commentId:string>")
.action(async (_options, commentId) => {
try {
const mutation = gql(`
mutation DeleteComment($id: String!) {
commentDelete(id: $id) {
success
}
}
`)

const client = getGraphQLClient()
const data = await client.request(mutation, { id: commentId })

if (!data.commentDelete.success) {
throw new CliError("Failed to delete comment")
}

console.log("✓ Comment deleted")
} catch (error) {
handleError(error, "Failed to delete comment")
}
})
2 changes: 2 additions & 0 deletions src/commands/issue/issue-comment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from "@cliffy/command"
import { commentAddCommand } from "./issue-comment-add.ts"
import { commentDeleteCommand } from "./issue-comment-delete.ts"
import { commentUpdateCommand } from "./issue-comment-update.ts"
import { commentListCommand } from "./issue-comment-list.ts"

Expand All @@ -9,5 +10,6 @@ export const commentCommand = new Command()
this.showHelp()
})
.command("add", commentAddCommand)
.command("delete", commentDeleteCommand)
.command("update", commentUpdateCommand)
.command("list", commentListCommand)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const snapshot = {};

snapshot[`Issue Comment Delete Command - Success 1`] = `
stdout:
"✓ Comment deleted
"
stderr:
""
`;
35 changes: 35 additions & 0 deletions test/commands/issue/issue-comment-delete.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { snapshotTest } from "@cliffy/testing"
import { commentDeleteCommand } from "../../../src/commands/issue/issue-comment-delete.ts"
import {
commonDenoArgs,
setupMockLinearServer,
} from "../../utils/test-helpers.ts"

// Test deleting a comment
await snapshotTest({
name: "Issue Comment Delete Command - Success",
meta: import.meta,
colors: false,
args: ["comment-uuid-123"],
denoArgs: commonDenoArgs,
async fn() {
const { cleanup } = await setupMockLinearServer([
{
queryName: "DeleteComment",
response: {
data: {
commentDelete: {
success: true,
},
},
},
},
])

try {
await commentDeleteCommand.parse()
} finally {
await cleanup()
}
},
})