|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import yargs from 'yargs';
- import { hideBin } from 'yargs/helpers';
- import {
- main,
- MainArgs,
- Presentation,
- PRESENTATION,
- } from './app';
-
- void main(
- yargs
- .scriptName('oblique')
- .usage(`Oblique Strategies - Be creative, pick constraints, get to work.
-
- Usage: $0 [-c <cards>] [-f] [-p <presentation>]`)
- .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()
- .alias('h', 'help')
- .alias('v', 'version')
- .wrap(yargs.terminalWidth())
- .parse(hideBin(process.argv)) as MainArgs,
- );
|