cli.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { app } from 'electron'
  2. export function parseArgs (argv: string[], cwd: string): any {
  3. if (argv[0].includes('node')) {
  4. argv = argv.slice(1)
  5. }
  6. return require('yargs/yargs')(argv.slice(1))
  7. .usage('tabby [command] [arguments]')
  8. .command('open [directory]', 'open a shell in a directory', {
  9. directory: { type: 'string', 'default': cwd },
  10. })
  11. .command(['run [command...]', '/k'], '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. .command('recent [index]', 'open a tab with a recent profile', {
  27. profileNumber: { type: 'number' },
  28. })
  29. .version(app.getVersion())
  30. .option('debug', {
  31. alias: 'd',
  32. describe: 'Show DevTools on start',
  33. type: 'boolean',
  34. })
  35. .option('hidden', {
  36. describe: 'Start minimized',
  37. type: 'boolean',
  38. })
  39. .help('help')
  40. .parse()
  41. }