CLI for Oblique Strategies.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import yargs from 'yargs';
  2. import { hideBin } from 'yargs/helpers';
  3. import {
  4. main,
  5. MainArgs,
  6. Presentation,
  7. PRESENTATION,
  8. } from './app';
  9. void main(
  10. yargs
  11. .scriptName('oblique')
  12. .usage(`Oblique Strategies - Be creative, pick constraints, get to work.
  13. Usage: $0 [-c <cards>] [-f] [-p <presentation>]`)
  14. .option('cards', {
  15. alias: 'c',
  16. 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]://",
  17. coerce: (c?: unknown) => {
  18. if (typeof c !== 'string') {
  19. return ['default'];
  20. }
  21. const theCards = c.split(';');
  22. if (theCards.length < 1) {
  23. return ['default'];
  24. }
  25. // dedupe so we don't have to generate some cards more likely than others
  26. return theCards.filter((card, i, cards) => cards.indexOf(card) === i);
  27. },
  28. default: 'default',
  29. })
  30. .option('formatted', {
  31. alias: 'f',
  32. description: 'Flag when the output should be formatted.',
  33. coerce: (c?: unknown) => Boolean(c),
  34. default: false,
  35. })
  36. .option('presentation', {
  37. alias: 'p',
  38. description: 'Selection of how the card should be presented.',
  39. choices: PRESENTATION,
  40. coerce: (c?: unknown): Presentation => {
  41. if (typeof c !== 'string') {
  42. return 'plain';
  43. }
  44. const maybePresentation = c as Presentation;
  45. if (!PRESENTATION.includes(maybePresentation)) {
  46. return 'plain';
  47. }
  48. return maybePresentation;
  49. },
  50. default: 'plain',
  51. })
  52. .help()
  53. .alias('h', 'help')
  54. .alias('v', 'version')
  55. .wrap(yargs.terminalWidth())
  56. .parse(hideBin(process.argv)) as MainArgs,
  57. );