tabby/app/lib/cli.ts

52 lines
1.7 KiB
TypeScript
Raw Normal View History

import { app } from 'electron'
2020-03-01 15:10:45 +00:00
export function parseArgs (argv: string[], cwd: string): any {
if (argv[0].includes('node')) {
argv = argv.slice(1)
}
2021-01-02 19:24:26 +00:00
return require('yargs/yargs')(argv.slice(1))
.usage('terminus [command] [arguments]')
.command('open [directory]', 'open a shell in a directory', {
directory: { type: 'string', 'default': cwd },
})
.command(['run [command...]', '/k'], 'run a command in the terminal', {
command: { type: 'string' },
})
.command('profile [profileName]', 'open a tab with specified profile', {
profileName: { type: 'string' },
})
.command('connect-ssh [connectionName]', 'open a tab for a saved SSH connection', {
connectionName: { type: 'string' },
})
.command('connect-serial [connectionName]', 'open a tab for a saved serial connection', {
connectionName: { type: 'string' },
})
.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',
}).positional('text', {
2020-02-05 12:16:31 +00:00
type: 'string',
})
})
.version('version', '', app.getVersion())
.option('debug', {
alias: 'd',
describe: 'Show DevTools on start',
2020-02-05 12:16:31 +00:00
type: 'boolean',
})
.option('hidden', {
describe: 'Start minimized',
2020-02-05 12:16:31 +00:00
type: 'boolean',
})
.option('version', {
alias: 'v',
describe: 'Show version and exit',
2020-02-05 12:16:31 +00:00
type: 'boolean',
})
.help('help')
2021-01-02 19:24:26 +00:00
.parse()
}