/** * Storage Remove Command * Remove a backup storage destination */ import { getBackupStorageByStorageId, removeBackupStorage } from '../../services/backup-storage'; import { askConfirm, withInterviewSession } from '../../services/bus-interview'; import { celiloIntro, celiloOutro } from '../prompts'; import type { CommandResult } from '../types'; export async function handleStorageRemove( args: string[], flags: Record = {}, ): Promise { try { celiloIntro('Remove Backup Storage'); const storageId = args[0]; if (!storageId) { return { success: false, error: 'Storage ID is required\n\nUsage: celilo storage remove ', }; } const storage = getBackupStorageByStorageId(storageId); if (!storage) { return { success: false, error: `Storage not found: ${storageId}` }; } if (!flags.force) { const confirmed = await withInterviewSession(() => askConfirm({ scope: `storage:${storage.storageId}`, key: 'remove', message: `Remove storage '${storage.storageId}' (${storage.name})?`, defaultValue: false, }), ); if (!confirmed) { return { success: false, error: 'Cancelled by user' }; } } removeBackupStorage(storage.id); celiloOutro(`Storage '${storage.storageId}' (${storage.name}) removed.`); return { success: true, message: `Removed storage: ${storage.storageId}` }; } catch (error) { return { success: false, error: `Failed to remove storage: ${error instanceof Error ? error.message : String(error)}`, }; } }