Files
modeling-app/rust/kcl-language-server/client/src/commands.ts
2025-03-04 22:21:12 -08:00

33 lines
838 B
TypeScript

/* eslint suggest-no-throw/suggest-no-throw: 0 */
import * as vscode from 'vscode'
import type { Cmd, CtxInit } from './ctx'
import { spawnSync } from 'child_process'
export function serverVersion(ctx: CtxInit): Cmd {
return async () => {
if (!ctx.serverPath) {
void vscode.window.showWarningMessage(
`kcl-language-server server is not running`
)
return
}
const { stdout } = spawnSync(ctx.serverPath, ['--version'], {
encoding: 'utf8',
})
const versionString = stdout.slice(`kcl-language-server `.length).trim()
void vscode.window.showInformationMessage(
`kcl-language-server version: ${versionString}`
)
}
}
export function openLogs(ctx: CtxInit): Cmd {
return async () => {
if (ctx.client.outputChannel) {
ctx.client.outputChannel.show()
}
}
}