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.
35 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createReadCommand = createReadCommand;
const commander_1 = require("commander");
const context_1 = require("../../core/context");
function createReadCommand() {
const command = new commander_1.Command('read');
command
.description('Read a context')
.argument('<tag>', 'Context tag')
.option('-s, --storage-path <path>', 'Custom storage path')
.option('-j, --json', 'Output as JSON')
.action(async (tag, options) => {
try {
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);
}
if (options.json) {
console.log(JSON.stringify({ [tag]: context }, null, 2));
}
else {
console.log(context.content);
}
}
catch (error) {
console.error(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
process.exit(1);
}
});
return command;
}
//# sourceMappingURL=read.js.map