-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdelete.ts
More file actions
43 lines (37 loc) · 1.25 KB
/
delete.ts
File metadata and controls
43 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { getClient } from "@repo/backlog-utils";
import { confirmOrExit, outputResult } from "@repo/cli-utils";
import consola from "consola";
import { BeeCommand, ENV_AUTH } from "../../lib/bee-command";
import * as opt from "../../lib/common-options";
const deleteDocument = new BeeCommand("delete")
.summary("Delete a document")
.description(`This action is irreversible.`)
.argument("<document>", "Document ID")
.option("-y, --yes", "Skip confirmation prompt")
.addOption(opt.json())
.envVars([...ENV_AUTH])
.examples([
{
description: "Delete a document (with confirmation)",
command: "bee document delete 12345",
},
{
description: "Delete a document without confirmation",
command: "bee document delete 12345 --yes",
},
])
.action(async (document, opts) => {
const confirmed = await confirmOrExit(
`Are you sure you want to delete document ${document}? This cannot be undone.`,
opts.yes,
);
if (!confirmed) {
return;
}
const { client } = await getClient();
const doc = await client.deleteDocument(document);
outputResult(doc, opts, (data) => {
consola.success(`Deleted document ${data.title} (ID: ${data.id})`);
});
});
export default deleteDocument;