2018-08-31 16:41:28 +03:00
|
|
|
import { app } from 'electron'
|
|
|
|
|
|
|
|
export function parseArgs (argv, cwd) {
|
|
|
|
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-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',
|
|
|
|
describe: 'Perform shell escaping'
|
|
|
|
}).positional('text', {
|
|
|
|
type: 'string'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.version('version', '', app.getVersion())
|
|
|
|
.option('debug', {
|
|
|
|
alias: 'd',
|
|
|
|
describe: 'Show DevTools on start',
|
|
|
|
type: 'boolean'
|
|
|
|
})
|
|
|
|
.option('version', {
|
|
|
|
alias: 'v',
|
|
|
|
describe: 'Show version and exit',
|
|
|
|
type: 'boolean'
|
|
|
|
})
|
|
|
|
.help('help')
|
2018-08-31 16:41:28 +03:00
|
|
|
.strict()
|
|
|
|
.parse(argv.slice(1))
|
|
|
|
}
|