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.
57 lines • 2.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createListCommand = createListCommand;
const commander_1 = require("commander");
const context_1 = require("../../core/context");
const common_1 = require("../../utils/common");
function createListCommand() {
const command = new commander_1.Command('list');
command
.description('List all contexts')
.option('-s, --storage-path <path>', 'Custom storage path')
.option('-j, --json', 'Output as JSON')
.option('-v, --verbose', 'Show detailed information')
.action(async (options) => {
try {
const contextManager = await context_1.ContextManager.create(options.storagePath);
if (options.verbose) {
const allContexts = await contextManager.getAll();
if (options.json) {
console.log(JSON.stringify(allContexts, null, 2));
}
else {
console.log(`\nFound ${Object.keys(allContexts).length} contexts:\n`);
for (const [tag, entry] of Object.entries(allContexts)) {
console.log(`Tag: ${tag}`);
console.log(`Created: ${(0, common_1.formatTimestamp)(entry.metadata.created)}`);
console.log(`Modified: ${(0, common_1.formatTimestamp)(entry.metadata.modified)}`);
console.log(`Categories: ${(0, common_1.categoriesToString)(entry.metadata.categories) || 'None'}`);
console.log(`Content: ${entry.content.substring(0, 100)}${entry.content.length > 100 ? '...' : ''}`);
console.log('---');
}
}
}
else {
const tags = await contextManager.list();
if (options.json) {
console.log(JSON.stringify(tags, null, 2));
}
else {
if (tags.length === 0) {
console.log('No contexts found');
}
else {
console.log(`Found ${tags.length} contexts:`);
tags.forEach(tag => console.log(` ${tag}`));
}
}
}
}
catch (error) {
console.error(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
process.exit(1);
}
});
return command;
}
//# sourceMappingURL=list.js.map