/** * ───────────────────────────────────────────── * SPB Git — Personal Git Platform * ───────────────────────────────────────────── * Author : Simon-Pierre Boucher * Contact : contact@spboucher.ai * File : cli/commands/rm.mjs * Purpose : `spbgit rm --confirm` — soft-delete with typed confirm * License : MIT © Simon-Pierre Boucher * ───────────────────────────────────────────── */ import pc from 'picocolors'; import { requireCliConfig } from '../lib/config.mjs'; import { api, EXIT } from '../lib/api.mjs'; import { prompt } from '../lib/ui.mjs'; export function registerRm(program) { program .command('rm ') .description('soft-delete a repository on the server (recoverable 30 days)') .option('--confirm', 'required flag — deletion asks you to retype the name', false) .action(async (name, opts) => { const config = requireCliConfig(); if (!opts.confirm) { console.error(pc.red('✗ Deletion requires --confirm')); process.exit(EXIT.USER); } console.log(pc.yellow(`\nThis moves ${pc.bold(name)} to the server trash (recoverable for 30 days).`)); const typed = await prompt(`Type ${pc.bold(name)} to confirm`); if (typed !== name) { console.error(pc.red('✗ Name mismatch — aborted.')); process.exit(EXIT.USER); } const result = await api(config, 'DELETE', `/api/v1/repos/${encodeURIComponent(name)}`); console.log(`${pc.green('✓')} ${result.deleted} deleted. ${pc.dim(result.note)}`); }); }