spb/spbgit Public MIT
SPB Git — the platform hosting itself
JavaScript 73.9%
CSS 11.7%
Nunjucks 11.6%
Shell 2.7%
1/**2 * ─────────────────────────────────────────────3 * SPB Git — Personal Git Platform4 * ─────────────────────────────────────────────5 * Author : Simon-Pierre Boucher6 * Contact : contact@spboucher.ai7 * File : cli/commands/rm.mjs8 * Purpose : `spbgit rm <name> --confirm` — soft-delete with typed confirm9 * License : MIT © Simon-Pierre Boucher10 * ─────────────────────────────────────────────11 */1213import pc from 'picocolors';14import { requireCliConfig } from '../lib/config.mjs';15import { api, EXIT } from '../lib/api.mjs';16import { prompt } from '../lib/ui.mjs';1718export function registerRm(program) {19 program20 .command('rm <name>')21 .description('soft-delete a repository on the server (recoverable 30 days)')22 .option('--confirm', 'required flag — deletion asks you to retype the name', false)23 .action(async (name, opts) => {24 const config = requireCliConfig();25 if (!opts.confirm) {26 console.error(pc.red('✗ Deletion requires --confirm'));27 process.exit(EXIT.USER);28 }29 console.log(pc.yellow(`\nThis moves ${pc.bold(name)} to the server trash (recoverable for 30 days).`));30 const typed = await prompt(`Type ${pc.bold(name)} to confirm`);31 if (typed !== name) {32 console.error(pc.red('✗ Name mismatch — aborted.'));33 process.exit(EXIT.USER);34 }35 const result = await api(config, 'DELETE', `/api/v1/repos/${encodeURIComponent(name)}`);36 console.log(`${pc.green('✓')} ${result.deleted} deleted. ${pc.dim(result.note)}`);37 });38}39