UNPKG

loccon

Version:

A simple local context storage and management tool with CLI and web interfaces. Store, search, and organize code snippets, notes, and development contexts with sharded JSON storage.

87 lines 3.52 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.createRemoveCommand = createRemoveCommand; const commander_1 = require("commander"); const context_1 = require("../../core/context"); const readline = __importStar(require("readline")); function createRemoveCommand() { const command = new commander_1.Command('remove'); command .description('Remove a context') .argument('<tag>', 'Context tag') .option('-s, --storage-path <path>', 'Custom storage path') .option('-f, --force', 'Force removal without confirmation') .action(async (tag, options) => { try { const contextManager = await context_1.ContextManager.create(options.storagePath); // Check if context exists const context = await contextManager.read(tag); if (!context) { console.error(`Context '${tag}' not found`); process.exit(1); } // Show confirmation unless forced if (!options.force) { const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const answer = await new Promise((resolve) => { rl.question(`Are you sure you want to remove context '${tag}'? (y/N): `, resolve); }); rl.close(); if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') { console.log('Removal cancelled'); return; } } const removed = await contextManager.remove(tag); if (removed) { console.log(`Removed context '${tag}'`); } else { console.error(`Failed to remove context '${tag}'`); process.exit(1); } } catch (error) { console.error(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`); process.exit(1); } }); return command; } //# sourceMappingURL=remove.js.map