mirror of
https://github.com/justinian/lexx.git
synced 2025-12-09 16:14:32 -08:00
Add -n option to generate Azgaar-style namebases
This commit is contained in:
21
lexx.ts
21
lexx.ts
@@ -1,13 +1,19 @@
|
||||
import { parseArgs } from 'util';
|
||||
import { build_language } from './src/definition'
|
||||
|
||||
const default_count = '20';
|
||||
|
||||
const { values, positionals } = parseArgs({
|
||||
args: Bun.argv.slice(2),
|
||||
options: {
|
||||
count: {
|
||||
type: 'string',
|
||||
short: 'c',
|
||||
default: '20',
|
||||
default: default_count,
|
||||
},
|
||||
namebase: {
|
||||
type: 'boolean',
|
||||
short: 'n',
|
||||
},
|
||||
},
|
||||
allowPositionals: true,
|
||||
@@ -20,10 +26,19 @@ if (positionals.length > 0)
|
||||
const def = await Bun.file(language).text();
|
||||
|
||||
try {
|
||||
if (typeof(values.count) != "string")
|
||||
values.count = default_count;
|
||||
|
||||
const lang = build_language(def);
|
||||
let words = lang.generate(parseInt(values.count));
|
||||
for (const w of words) {
|
||||
console.log(`${w[0]}\t\t/${w[1]}/`);
|
||||
|
||||
if (values.namebase) {
|
||||
let ws = words.map(w => w[0]);
|
||||
console.log(ws.join(','));
|
||||
} else {
|
||||
for (const w of words) {
|
||||
console.log(`${w[0]}\t\t/${w[1]}/`);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user