import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import { main, MainArgs, Presentation, PRESENTATION, } from './app'; void main( yargs .option('cards', { alias: 'c', description: "List of source for generating cards. Can have 'default', a pipe-delimited string starting with 'text:' or a URL starting with file:/// or http[s]://", coerce: (c?: unknown) => { if (typeof c !== 'string') { return ['default']; } const theCards = c.split(';'); if (theCards.length < 1) { return ['default']; } // dedupe so we don't have to generate some cards more likely than others return theCards.filter((card, i, cards) => cards.indexOf(card) === i); }, default: 'default', }) .option('formatted', { alias: 'f', description: 'Flag when the output should be formatted.', coerce: (c?: unknown) => Boolean(c), default: false, }) .option('presentation', { alias: 'p', description: 'Selection of how the card should be presented.', choices: PRESENTATION, coerce: (c?: unknown): Presentation => { if (typeof c !== 'string') { return 'plain'; } const maybePresentation = c as Presentation; if (!PRESENTATION.includes(maybePresentation)) { return 'plain'; } return maybePresentation; }, default: 'plain', }) .help() .parse(hideBin(process.argv)) as MainArgs, );