From f66f144f2e62b9668f40de42258bf99011bf5b4e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 1 Oct 2024 23:33:18 +0800 Subject: [PATCH] :sparkles: CLI Loading server stats and traces --- .idea/inspectionProfiles/Project_Default.xml | 6 + cli/index.ts | 14 +- cli/src/cmd/info.ts | 128 +++++++++++++++++++ cli/src/cmd/login.ts | 2 +- cli/src/cmd/status.ts | 46 +++++++ cli/src/utils/auth.ts | 2 +- pkg/navi/config.go | 2 + pkg/navi/metrics.go | 8 +- pkg/sideload/statistics.go | 6 + 9 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 cli/src/cmd/info.ts create mode 100644 cli/src/cmd/status.ts diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..cb83045 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/cli/index.ts b/cli/index.ts index 7bf29a8..0d2b755 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -5,12 +5,18 @@ import chalk from "chalk" import { LoginCommand } from "./src/cmd/login.ts" import { LogoutCommand } from "./src/cmd/logout.ts" import { ListServerCommand } from "./src/cmd/list.ts" +import { StatusCommand } from "./src/cmd/status.ts" +import { InfoCommand } from "./src/cmd/info.ts" const [node, app, ...args] = process.argv -console.log( - chalk.yellow(figlet.textSync("RoadSign CLI", { horizontalLayout: "default", verticalLayout: "default" })) -) +const ENABLE_STARTUP_ASCII_ART = false + +if (process.env["ENABLE_STARTUP_ASCII_ART"] || ENABLE_STARTUP_ASCII_ART) { + console.log( + chalk.yellow(figlet.textSync("RoadSign CLI", { horizontalLayout: "default", verticalLayout: "default" })) + ) +} const cli = new Cli({ binaryLabel: `RoadSign CLI`, @@ -21,4 +27,6 @@ const cli = new Cli({ cli.register(LoginCommand) cli.register(LogoutCommand) cli.register(ListServerCommand) +cli.register(StatusCommand) +cli.register(InfoCommand) cli.runExit(args) \ No newline at end of file diff --git a/cli/src/cmd/info.ts b/cli/src/cmd/info.ts new file mode 100644 index 0000000..a603f54 --- /dev/null +++ b/cli/src/cmd/info.ts @@ -0,0 +1,128 @@ +import { Command, Option, type Usage } from "clipanion" +import { RsConfig } from "../utils/config.ts" +import { createAuthHeader } from "../utils/auth.ts" +import chalk from "chalk" +import ora from "ora" + +export class InfoCommand extends Command { + static paths = [[`info`], [`if`]] + static usage: Usage = { + category: `Networking`, + description: `Fetching the stats of RoadSign Server`, + details: `Fetching the configured things amount and other things of a connected server`, + examples: [["Fetch stats from labeled server", `info