2018-08-31 13:41:28 +00:00
|
|
|
import { app } from 'electron'
|
|
|
|
|
2020-03-01 15:10:45 +00:00
|
|
|
export function parseArgs (argv: string[], cwd: string): any {
|
2018-08-31 13:41:28 +00:00
|
|
|
if (argv[0].includes('node')) {
|
|
|
|
argv = argv.slice(1)
|
|
|
|
}
|
|
|
|
|
2021-01-02 19:24:26 +00:00
|
|
|
return require('yargs/yargs')(argv.slice(1))
|
2021-06-29 21:57:04 +00:00
|
|
|
.usage('tabby [command] [arguments]')
|
2018-08-31 13:41:28 +00:00
|
|
|
.command('open [directory]', 'open a shell in a directory', {
|
|
|
|
directory: { type: 'string', 'default': cwd },
|
|
|
|
})
|
2021-05-16 17:40:54 +00:00
|
|
|
.command(['run [command...]', '/k'], 'run a command in the terminal', {
|
2018-08-31 13:41:28 +00:00
|
|
|
command: { type: 'string' },
|
|
|
|
})
|
2018-12-16 22:13:14 +00:00
|
|
|
.command('profile [profileName]', 'open a tab with specified profile', {
|
|
|
|
profileName: { type: 'string' },
|
|
|
|
})
|
2018-09-23 14:33:57 +00:00
|
|
|
.command('paste [text]', 'paste stdin into the active tab', yargs => {
|
|
|
|
return yargs.option('escape', {
|
|
|
|
alias: 'e',
|
|
|
|
type: 'boolean',
|
2020-02-05 12:16:31 +00:00
|
|
|
describe: 'Perform shell escaping',
|
2018-09-23 14:33:57 +00:00
|
|
|
}).positional('text', {
|
2020-02-05 12:16:31 +00:00
|
|
|
type: 'string',
|
2018-09-23 14:33:57 +00:00
|
|
|
})
|
|
|
|
})
|
2022-02-23 19:36:24 +00:00
|
|
|
.command('recent [index]', 'open a tab with a recent profile', {
|
|
|
|
profileNumber: { type: 'number' },
|
|
|
|
})
|
2021-12-12 11:03:10 +00:00
|
|
|
.version(app.getVersion())
|
2018-09-23 14:33:57 +00:00
|
|
|
.option('debug', {
|
|
|
|
alias: 'd',
|
|
|
|
describe: 'Show DevTools on start',
|
2020-02-05 12:16:31 +00:00
|
|
|
type: 'boolean',
|
2018-09-23 14:33:57 +00:00
|
|
|
})
|
2018-11-11 12:24:27 +00:00
|
|
|
.option('hidden', {
|
|
|
|
describe: 'Start minimized',
|
2020-02-05 12:16:31 +00:00
|
|
|
type: 'boolean',
|
2018-11-11 12:24:27 +00:00
|
|
|
})
|
2018-09-23 14:33:57 +00:00
|
|
|
.help('help')
|
2021-01-02 19:24:26 +00:00
|
|
|
.parse()
|
2018-08-31 13:41:28 +00:00
|
|
|
}
|