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