mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-09 01:51:39 +00:00
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import chalk from 'chalk'
|
|
import { authAndSetupMachineIfNeeded } from '@/ui/auth'
|
|
import { initializeToken } from '@/ui/tokenInit'
|
|
import { maybeAutoStartServer } from '@/utils/autoStartServer'
|
|
import { DSH_PERMISSION_MODES } from '@hapi/protocol'
|
|
import type { CommandDefinition } from './types'
|
|
import { parseRemoteAgentCommandOptions } from './agentCommandOptions'
|
|
|
|
export function parseDshCommandOptions(commandArgs: string[]) {
|
|
const options = parseRemoteAgentCommandOptions(commandArgs, DSH_PERMISSION_MODES)
|
|
return { ...options, startingMode: 'remote' as const }
|
|
}
|
|
|
|
export const dshCommand: CommandDefinition = {
|
|
name: 'dsh',
|
|
requiresRuntimeAssets: false,
|
|
run: async ({ commandArgs }) => {
|
|
try {
|
|
const options = parseDshCommandOptions(commandArgs)
|
|
await initializeToken()
|
|
await maybeAutoStartServer()
|
|
await authAndSetupMachineIfNeeded()
|
|
|
|
const { runDsh } = await import('@/dsh/runDsh')
|
|
await runDsh(options)
|
|
} catch (error) {
|
|
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error')
|
|
if (process.env.DEBUG) console.error(error)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
}
|