|
| 1 | +import type { Command } from "commander"; |
| 2 | + |
| 3 | +import { Logger } from "../../../../logger.js"; |
| 4 | +import { printActionResult, resolveCommandContext, runCommandAction } from "../../../../utils/cli.js"; |
| 5 | +import { parseBrowserTimeoutSeconds } from "../../../shared/cookie-login.js"; |
| 6 | + |
| 7 | +import { xAdapter } from "../adapter.js"; |
| 8 | + |
| 9 | +import type { PlatformCapability } from "../../../../core/runtime/platform-definition.js"; |
| 10 | + |
| 11 | +export const xDeleteCapability: PlatformCapability = { |
| 12 | + id: "delete", |
| 13 | + register(command: Command) { |
| 14 | + command |
| 15 | + .command("delete <target>") |
| 16 | + .alias("remove") |
| 17 | + .description("Delete your own X post by URL or tweet ID through a browser-backed action flow") |
| 18 | + .option("--account <name>", "Optional override for a specific saved X session") |
| 19 | + .option("--browser", "Force the delete through the shared AutoCLI browser profile instead of the invisible browser-backed path") |
| 20 | + .option("--browser-timeout <seconds>", "Maximum seconds to allow the browser action to complete", parseBrowserTimeoutSeconds) |
| 21 | + .action(async (target, options, cmd) => { |
| 22 | + const ctx = resolveCommandContext(cmd); |
| 23 | + const logger = new Logger(ctx); |
| 24 | + const spinner = logger.spinner("Deleting X post..."); |
| 25 | + await runCommandAction({ |
| 26 | + spinner, |
| 27 | + successMessage: "X post deleted.", |
| 28 | + action: () => |
| 29 | + xAdapter.deleteTweet({ |
| 30 | + account: options.account, |
| 31 | + target, |
| 32 | + browser: Boolean(options.browser), |
| 33 | + browserTimeoutSeconds: options.browserTimeout as number | undefined, |
| 34 | + }), |
| 35 | + onSuccess: (result) => { |
| 36 | + printActionResult(result, ctx.json); |
| 37 | + }, |
| 38 | + }); |
| 39 | + }); |
| 40 | + }, |
| 41 | +}; |
0 commit comments