**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:
parent
b6cacec4f8
commit
8dd743a06a
1 changed files with 17 additions and 9 deletions
26
src/cli.ts
26
src/cli.ts
|
|
@ -345,7 +345,9 @@ program
|
|||
fs.writeFileSync(outputFile, JSON.stringify(data, null, 2))
|
||||
|
||||
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) {
|
||||
console.error('Error:', (error as Error).message)
|
||||
process.exit(1)
|
||||
|
|
@ -375,7 +377,9 @@ program
|
|||
const result = await db.restore(data, { clearExisting: options.clear })
|
||||
|
||||
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) {
|
||||
console.error('Error:', (error as Error).message)
|
||||
process.exit(1)
|
||||
|
|
@ -384,7 +388,9 @@ program
|
|||
|
||||
program
|
||||
.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')
|
||||
.option('-c, --clear', 'Clear existing data before importing', false)
|
||||
.action(async (filename, options) => {
|
||||
|
|
@ -402,10 +408,14 @@ program
|
|||
const data = JSON.parse(fileContent)
|
||||
|
||||
// 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(`Imported ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`)
|
||||
console.log(
|
||||
`Imported ${result.nounsRestored} nouns and ${result.verbsRestored} verbs`
|
||||
)
|
||||
} catch (error) {
|
||||
console.error('Error:', (error as Error).message)
|
||||
process.exit(1)
|
||||
|
|
@ -746,7 +756,7 @@ program
|
|||
}
|
||||
})
|
||||
|
||||
// Add examples to help text
|
||||
// Add demo to help text
|
||||
program.addHelpText(
|
||||
'after',
|
||||
`
|
||||
|
|
@ -881,7 +891,7 @@ completion.tree({
|
|||
},
|
||||
'completion-setup': {},
|
||||
init: {},
|
||||
help: {},
|
||||
help: {}
|
||||
})
|
||||
|
||||
// Initialize autocomplete
|
||||
|
|
@ -1271,8 +1281,6 @@ program
|
|||
console.log('Autocomplete setup complete. Please restart your shell.')
|
||||
})
|
||||
|
||||
|
||||
// Parse command line arguments
|
||||
|
||||
|
||||
program.parse()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue