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.

45 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSearchCommand = createSearchCommand; const commander_1 = require("commander"); const context_1 = require("../../core/context"); const common_1 = require("../../utils/common"); function createSearchCommand() { const command = new commander_1.Command('search'); command .description('Search contexts') .argument('<query>', 'Search query') .option('-s, --storage-path <path>', 'Custom storage path') .option('-j, --json', 'Output as JSON') .option('-f, --fuzzy', 'Use fuzzy search with Fuse.js') .action(async (query, options) => { try { const contextManager = await context_1.ContextManager.create(options.storagePath); const results = await contextManager.search(query, options.fuzzy); if (options.json) { console.log(JSON.stringify(results, null, 2)); } else { if (results.length === 0) { console.log(`No contexts found matching '${query}'`); } else { console.log(`\nFound ${results.length} matching contexts:\n`); for (const result of results) { console.log(`Tag: ${result.tag}`); console.log(`Created: ${(0, common_1.formatTimestamp)(result.entry.metadata.created)}`); console.log(`Categories: ${(0, common_1.categoriesToString)(result.entry.metadata.categories) || 'None'}`); console.log(`Content: ${result.entry.content.substring(0, 150)}${result.entry.content.length > 150 ? '...' : ''}`); console.log('---'); } } } } catch (error) { console.error(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`); process.exit(1); } }); return command; } //# sourceMappingURL=search.js.map