diff --git a/lexx.ts b/lexx.ts index 39b8f2b..eb0ae13 100644 --- a/lexx.ts +++ b/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);