cli.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { app } from 'electron'
  2. export function parseArgs (argv, cwd) {
  3. if (argv[0].includes('node')) {
  4. argv = argv.slice(1)
  5. }
  6. return require('yargs')
  7. .usage('terminus [command] [arguments]')
  8. .command('open [directory]', 'open a shell in a directory', {
  9. directory: { type: 'string', 'default': cwd },
  10. })
  11. .command('run [command...]', 'run a command in the terminal', {
  12. command: { type: 'string' },
  13. })
  14. .command('profile [profileName]', 'open a tab with specified profile', {
  15. profileName: { type: 'string' },
  16. })
  17. .command('paste [text]', 'paste stdin into the active tab', yargs => {
  18. return yargs.option('escape', {
  19. alias: 'e',
  20. type: 'boolean',
  21. describe: 'Perform shell escaping',
  22. }).positional('text', {
  23. type: 'string',
  24. })
  25. })
  26. .version('version', '', app.getVersion())
  27. .option('debug', {
  28. alias: 'd',
  29. describe: 'Show DevTools on start',
  30. type: 'boolean',
  31. })
  32. .option('hidden', {
  33. describe: 'Start minimized',
  34. type: 'boolean',
  35. })
  36. .option('version', {
  37. alias: 'v',
  38. describe: 'Show version and exit',
  39. type: 'boolean',
  40. })
  41. .help('help')
  42. .parse(argv.slice(1))
  43. }