**refactor(cli): reformat logging and descriptions for improved readability**

### Changes:
- **src/cli.ts**:
  - Reformatted multi-line logging statements using consistent indentation for better readability.
  - Reformatted `import-sparse` command description for consistent line wrapping.
  - Adjusted function definitions and options configurations for clarity.
  - Improved inline comments (`examples` → `demo`) for accurate context.

### Purpose:
Enhanced code readability and consistency by reformatting logging, descriptions, and comments. Improved maintainability through structured formatting and updated context-specific references.
This commit is contained in:
David Snelling 2025-06-23 10:59:37 -07:00
parent b6cacec4f8
commit 8dd743a06a

View file

@ -345,7 +345,9 @@ program
fs.writeFileSync(outputFile, JSON.stringify(data, null, 2)) fs.writeFileSync(outputFile, JSON.stringify(data, null, 2))
console.log(`Data backed up successfully to ${outputFile}`) console.log(`Data backed up successfully to ${outputFile}`)
console.log(`Backed up ${data.nouns.length} nouns and ${data.verbs.length} verbs`) console.log(
`Backed up ${data.nouns.length} nouns and ${data.verbs.length} verbs`
)
} catch (error) { } catch (error) {
console.error('Error:', (error as Error).message) console.error('Error:', (error as Error).message)
process.exit(1) process.exit(1)
@ -375,7 +377,9 @@ program
const result = await db.restore(data, { clearExisting: options.clear }) const result = await db.restore(data, { clearExisting: options.clear })
console.log(`Data restored successfully from ${filename}`) console.log(`Data restored successfully from ${filename}`)
console.log(`Restored ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`) console.log(
`Restored ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`
)
} catch (error) { } catch (error) {
console.error('Error:', (error as Error).message) console.error('Error:', (error as Error).message)
process.exit(1) process.exit(1)
@ -384,7 +388,9 @@ program
program program
.command('import-sparse') .command('import-sparse')
.description('Import sparse data (without vectors) from a JSON file into the database') .description(
'Import sparse data (without vectors) from a JSON file into the database'
)
.argument('<filename>', 'Input JSON file') .argument('<filename>', 'Input JSON file')
.option('-c, --clear', 'Clear existing data before importing', false) .option('-c, --clear', 'Clear existing data before importing', false)
.action(async (filename, options) => { .action(async (filename, options) => {
@ -402,10 +408,14 @@ program
const data = JSON.parse(fileContent) const data = JSON.parse(fileContent)
// Import the sparse data // Import the sparse data
const result = await db.importSparseData(data, { clearExisting: options.clear }) const result = await db.importSparseData(data, {
clearExisting: options.clear
})
console.log(`Sparse data imported successfully from ${filename}`) console.log(`Sparse data imported successfully from ${filename}`)
console.log(`Imported ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`) console.log(
`Imported ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`
)
} catch (error) { } catch (error) {
console.error('Error:', (error as Error).message) console.error('Error:', (error as Error).message)
process.exit(1) process.exit(1)
@ -746,7 +756,7 @@ program
} }
}) })
// Add examples to help text // Add demo to help text
program.addHelpText( program.addHelpText(
'after', 'after',
` `
@ -881,7 +891,7 @@ completion.tree({
}, },
'completion-setup': {}, 'completion-setup': {},
init: {}, init: {},
help: {}, help: {}
}) })
// Initialize autocomplete // Initialize autocomplete
@ -1271,8 +1281,6 @@ program
console.log('Autocomplete setup complete. Please restart your shell.') console.log('Autocomplete setup complete. Please restart your shell.')
}) })
// Parse command line arguments // Parse command line arguments
program.parse() program.parse()