🎉 Initial Commit of next version RoadSign CLI

This commit is contained in:
2024-10-01 22:19:27 +08:00
parent 28d3a3fa06
commit 632d37caf5
12 changed files with 415 additions and 1 deletions

26
cli/src/cmd/list.ts Normal file
View File

@@ -0,0 +1,26 @@
import { Command, type Usage } from "clipanion"
import { RsConfig } from "../utils/config.ts"
import chalk from "chalk"
export class ListServerCommand extends Command {
static paths = [[`list`], [`ls`]]
static usage: Usage = {
category: `Networking`,
description: `List all connected RoadSign Sideload Services`,
details: `Listing all servers that already saved in RoadSign CLI configuration file`,
examples: [["List all", `list`]]
}
async execute() {
const config = await RsConfig.getInstance()
for (let idx = 0; idx < config.config.servers.length; idx++) {
const server = config.config.servers[idx]
this.context.stdout.write(`${idx + 1}. ${chalk.bold(server.label)} ${chalk.gray(`(${server.url})`)}\n`)
}
this.context.stdout.write("\n" + chalk.cyan(`Connected ${config.config.servers.length} server(s) in total.`) + "\n")
process.exit(0)
}
}