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.

54 lines 2.14 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const context_1 = require("../core/context"); const add_1 = require("./commands/add"); const read_1 = require("./commands/read"); const list_1 = require("./commands/list"); const search_1 = require("./commands/search"); const remove_1 = require("./commands/remove"); const web_1 = require("./commands/web"); const utils_1 = require("./utils"); const server_1 = require("../web/server"); const program = new commander_1.Command(); program .name('loccon') .description('Local context storage and management tool') .version((0, utils_1.getVersionString)()); // Add subcommands program.addCommand((0, add_1.createAddCommand)()); program.addCommand((0, read_1.createReadCommand)()); program.addCommand((0, list_1.createListCommand)()); program.addCommand((0, search_1.createSearchCommand)()); program.addCommand((0, remove_1.createRemoveCommand)()); program.addCommand((0, web_1.createWebCommand)()); // Handle special cases for main command behavior program .argument('[tag]', 'Context tag to read (returns full JSON)') .option('-s, --storage-path <path>', 'Custom storage path') .action(async (tag, options) => { try { if (tag) { // loccon <tag> → Return entire JSON for specific tag const contextManager = await context_1.ContextManager.create(options?.storagePath); const context = await contextManager.read(tag); if (!context) { console.error(`Context '${tag}' not found`); process.exit(1); } console.log(JSON.stringify({ [tag]: context }, null, 2)); } else { // loccon → Start web interface on port 5069 await (0, server_1.startWebServer)(5069, options?.storagePath, true); } } catch (error) { console.error(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`); process.exit(1); } }); // Parse command line arguments program.parse(); //# sourceMappingURL=index.js.map