hunspell-reader
Version:
A library for reading Hunspell Dictionary Files
22 lines • 859 B
JavaScript
// cSpell:ignore findup
import { Command } from 'commander';
import { parseAffFile } from './affReader.js';
import { affToDicInfo } from './affToDicInfo.js';
import { escapeUnicodeCode } from './textUtils.js';
export function getCommand() {
const commander = new Command('cspell-dict-info');
commander
.arguments('<hunspell_aff_file> <locale>')
.description('Display the CSpell Dictionary Information')
.action(action);
return commander;
}
async function action(hunspellFile, locale) {
const baseFile = hunspellFile.replace(/\.(dic|aff)$/, '');
const affFile = baseFile + '.aff';
const aff = await parseAffFile(affFile);
const info = affToDicInfo(aff, locale);
const rawJson = JSON.stringify(info, undefined, 2);
console.log(escapeUnicodeCode(rawJson));
}
//# sourceMappingURL=commandDictInfo.js.map