Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for a Quick Connect CLI command #9383

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export function parseArgs (argv: string[], cwd: string): any {
.command('recent [index]', 'open a tab with a recent profile', {
profileNumber: { type: 'number' },
})
.command('quickConnect <providerId> <query>', 'open a tab for specified quick connect provider', yargs => {
return yargs.positional('providerId', {
describe: 'The name of a quick connect profile provider',
type: 'string',
choices: ['ssh', 'telnet'],
}).positional('query', {
describe: 'The quick connect query string',
type: 'string',
})
})
.version(app.getVersion())
.option('debug', {
alias: 'd',
Expand Down
20 changes: 20 additions & 0 deletions tabby-core/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'
import { HostAppService } from './api/hostApp'
import { CLIHandler, CLIEvent } from './api/cli'
import { HostWindowService } from './api/hostWindow'
import { QuickConnectProfileProvider } from './api/profileProvider'
import { ProfilesService } from './services/profiles.service'

@Injectable()
Expand All @@ -27,6 +28,10 @@ export class ProfileCLIHandler extends CLIHandler {
this.handleOpenRecentProfile(event.argv.profileNumber)
return true
}
if (op === 'quickConnect') {
this.handleOpenQuickConnect(event.argv.providerId, event.argv.query)
return true
}
return false
}

Expand All @@ -48,6 +53,21 @@ export class ProfileCLIHandler extends CLIHandler {
this.profiles.openNewTabForProfile(profiles[profileNumber])
this.hostWindow.bringToFront()
}

private async handleOpenQuickConnect (providerId: string, query: string) {
const provider = this.profiles.getProviders().find(x => x.id === providerId)
if(!provider || !(provider instanceof QuickConnectProfileProvider)) {
console.error(`Requested provider "${providerId}" not found`)
return
}
const profile = provider.quickConnect(query)
if(!profile) {
console.error(`Could not parse quick connect query "${query}"`)
return
}
this.profiles.openNewTabForProfile(profile)
this.hostWindow.bringToFront()
}
}

@Injectable()
Expand Down