mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 13:30:02 +00:00
CLI options to start SSH and serial connections - fixes #2785
This commit is contained in:
parent
3f40098ffb
commit
7506670dfb
@ -16,6 +16,12 @@ export function parseArgs (argv: string[], cwd: string): any {
|
||||
.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',
|
||||
|
30
terminus-serial/src/cli.ts
Normal file
30
terminus-serial/src/cli.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { CLIHandler, CLIEvent, ConfigService } from 'terminus-core'
|
||||
import { SerialService } from './services/serial.service'
|
||||
|
||||
@Injectable()
|
||||
export class SerialCLIHandler extends CLIHandler {
|
||||
firstMatchOnly = true
|
||||
priority = 0
|
||||
|
||||
constructor (
|
||||
private serial: SerialService,
|
||||
private config: ConfigService,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
|
||||
async handle (event: CLIEvent): Promise<boolean> {
|
||||
const op = event.argv._[0]
|
||||
|
||||
if (op === 'connect-serial') {
|
||||
const connection = this.config.store.serial.connections.find(x => x.name === event.argv.connectionName)
|
||||
if (connection) {
|
||||
this.serial.connect(connection)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ToastrModule } from 'ngx-toastr'
|
||||
import TerminusCoreModule, { ToolbarButtonProvider, ConfigProvider, TabRecoveryProvider, HotkeyProvider } from 'terminus-core'
|
||||
import TerminusCoreModule, { ToolbarButtonProvider, ConfigProvider, TabRecoveryProvider, HotkeyProvider, CLIHandler } from 'terminus-core'
|
||||
import { SettingsTabProvider } from 'terminus-settings'
|
||||
import TerminusTerminalModule from 'terminus-terminal'
|
||||
|
||||
@ -16,6 +16,7 @@ import { SerialConfigProvider } from './config'
|
||||
import { SerialSettingsTabProvider } from './settings'
|
||||
import { RecoveryProvider } from './recoveryProvider'
|
||||
import { SerialHotkeyProvider } from './hotkeys'
|
||||
import { SerialCLIHandler } from './cli'
|
||||
|
||||
/** @hidden */
|
||||
@NgModule({
|
||||
@ -33,6 +34,7 @@ import { SerialHotkeyProvider } from './hotkeys'
|
||||
{ provide: SettingsTabProvider, useClass: SerialSettingsTabProvider, multi: true },
|
||||
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
||||
{ provide: HotkeyProvider, useClass: SerialHotkeyProvider, multi: true },
|
||||
{ provide: CLIHandler, useClass: SerialCLIHandler, multi: true },
|
||||
],
|
||||
entryComponents: [
|
||||
EditConnectionModalComponent,
|
||||
|
30
terminus-ssh/src/cli.ts
Normal file
30
terminus-ssh/src/cli.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { CLIHandler, CLIEvent, ConfigService } from 'terminus-core'
|
||||
import { SSHService } from './services/ssh.service'
|
||||
|
||||
@Injectable()
|
||||
export class SSHCLIHandler extends CLIHandler {
|
||||
firstMatchOnly = true
|
||||
priority = 0
|
||||
|
||||
constructor (
|
||||
private ssh: SSHService,
|
||||
private config: ConfigService,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
|
||||
async handle (event: CLIEvent): Promise<boolean> {
|
||||
const op = event.argv._[0]
|
||||
|
||||
if (op === 'connect-ssh') {
|
||||
const connection = this.config.store.ssh.connections.find(x => x.name === event.argv.connectionName)
|
||||
if (connection) {
|
||||
this.ssh.connect(connection)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ToastrModule } from 'ngx-toastr'
|
||||
import TerminusCoreModule, { ToolbarButtonProvider, ConfigProvider, TabRecoveryProvider, HotkeyProvider, TabContextMenuItemProvider } from 'terminus-core'
|
||||
import TerminusCoreModule, { ToolbarButtonProvider, ConfigProvider, TabRecoveryProvider, HotkeyProvider, TabContextMenuItemProvider, CLIHandler } from 'terminus-core'
|
||||
import { SettingsTabProvider } from 'terminus-settings'
|
||||
import TerminusTerminalModule from 'terminus-terminal'
|
||||
|
||||
@ -20,6 +20,7 @@ import { SSHSettingsTabProvider } from './settings'
|
||||
import { RecoveryProvider } from './recoveryProvider'
|
||||
import { SSHHotkeyProvider } from './hotkeys'
|
||||
import { WinSCPContextMenu } from './winSCPIntegration'
|
||||
import { SSHCLIHandler } from './cli'
|
||||
|
||||
/** @hidden */
|
||||
@NgModule({
|
||||
@ -38,6 +39,7 @@ import { WinSCPContextMenu } from './winSCPIntegration'
|
||||
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
||||
{ provide: HotkeyProvider, useClass: SSHHotkeyProvider, multi: true },
|
||||
{ provide: TabContextMenuItemProvider, useClass: WinSCPContextMenu, multi: true },
|
||||
{ provide: CLIHandler, useClass: SSHCLIHandler, multi: true },
|
||||
],
|
||||
entryComponents: [
|
||||
EditConnectionModalComponent,
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import * as fs from 'mz/fs'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ToolbarButtonProvider, ToolbarButton, ElectronService, ConfigService, SelectorOption, AppService } from 'terminus-core'
|
||||
|
||||
@ -15,18 +14,6 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
private terminal: TerminalService,
|
||||
) {
|
||||
super()
|
||||
if (!electron.process.env.TERMINUS_DEV) {
|
||||
setImmediate(async () => {
|
||||
const argv: string[] = electron.process.argv
|
||||
for (const arg of argv.slice(1).concat([electron.process.argv0])) {
|
||||
if (await fs.exists(arg)) {
|
||||
if ((await fs.stat(arg)).isDirectory()) {
|
||||
this.terminal.openTab(undefined, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async activate () {
|
||||
|
@ -101,7 +101,6 @@ module.exports = options => {
|
||||
'windows-native-registry',
|
||||
'windows-process-tree',
|
||||
'windows-process-tree/build/Release/windows_process_tree.node',
|
||||
'yargs/yargs',
|
||||
/^@angular/,
|
||||
/^@ng-bootstrap/,
|
||||
/^rxjs/,
|
||||
|
Loading…
x
Reference in New Issue
Block a user