CLI update

This commit is contained in:
Ryan Huang
2024-04-18 13:05:25 -04:00
parent 584e503de0
commit 8f5925f8a1
5 changed files with 100 additions and 19 deletions

View File

@ -1,4 +1,4 @@
import { text, type SimpleLogger } from "@lmstudio/lms-common";
import { makePrettyError, text, type SimpleLogger } from "@lmstudio/lms-common";
import { LMStudioClient } from "@lmstudio/sdk";
import chalk from "chalk";
import { checkHttpServer, getServerLastStatus } from "./subcommands/server";
@ -13,13 +13,15 @@ export async function createClient(logger: SimpleLogger) {
port = 1234;
}
if (!(await checkHttpServer(logger, port))) {
logger.errorWithoutPrefix(text`
${"\n"}${chalk.redBright(text`
LM Studio server is not running. To start the server, run the following command:
`)}
logger.errorWithoutPrefix(
makePrettyError(text`
${chalk.redBright(text`
LM Studio server is not running. To start the server, run the following command:
`)}
${chalk.yellow("lms start ")}${chalk.gray("[--port <PORT>] [--cors=true|false]")}
`);
${chalk.yellow("lms server start ")}${chalk.gray("[--port <PORT>] [--cors=true|false]")}
`).message,
);
process.exit(1);
}
const baseUrl = `ws://127.0.0.1:${port}`;