refactor: polish providers cli status
This commit is contained in:
11
src/cli/command-options.ts
Normal file
11
src/cli/command-options.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { Command } from "commander";
|
||||
|
||||
export function hasExplicitOptions(
|
||||
command: Command,
|
||||
names: readonly string[],
|
||||
): boolean {
|
||||
if (typeof command.getOptionValueSource !== "function") {
|
||||
return false;
|
||||
}
|
||||
return names.some((name) => command.getOptionValueSource(name) === "cli");
|
||||
}
|
||||
@@ -662,7 +662,8 @@ Examples:
|
||||
clawdbot status --json # machine-readable output
|
||||
clawdbot status --usage # show provider usage/quota snapshots
|
||||
clawdbot status --deep # run provider probes (WA + Telegram + Discord + Slack + Signal)
|
||||
clawdbot status --deep --timeout 5000 # tighten probe timeout`,
|
||||
clawdbot status --deep --timeout 5000 # tighten probe timeout
|
||||
clawdbot providers status # gateway provider runtime + probes`,
|
||||
)
|
||||
.action(async (opts) => {
|
||||
const verbose = Boolean(opts.verbose || opts.debug);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
providersStatusCommand,
|
||||
} from "../commands/providers.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { hasExplicitOptions } from "./command-options.js";
|
||||
|
||||
const optionNamesAdd = [
|
||||
"provider",
|
||||
@@ -30,18 +31,6 @@ const optionNamesAdd = [
|
||||
|
||||
const optionNamesRemove = ["provider", "account", "delete"] as const;
|
||||
|
||||
function hasExplicitOptions(
|
||||
command: Command,
|
||||
names: readonly string[],
|
||||
): boolean {
|
||||
return names.some((name) => {
|
||||
if (typeof command.getOptionValueSource !== "function") {
|
||||
return false;
|
||||
}
|
||||
return command.getOptionValueSource(name) === "cli";
|
||||
});
|
||||
}
|
||||
|
||||
export function registerProvidersCli(program: Command) {
|
||||
const providers = program
|
||||
.command("providers")
|
||||
@@ -64,7 +53,7 @@ export function registerProvidersCli(program: Command) {
|
||||
|
||||
providers
|
||||
.command("status")
|
||||
.description("Show gateway provider status")
|
||||
.description("Show gateway provider status (use status --deep for local)")
|
||||
.option("--probe", "Probe provider credentials", false)
|
||||
.option("--timeout <ms>", "Timeout in ms", "10000")
|
||||
.option("--json", "Output JSON", false)
|
||||
|
||||
Reference in New Issue
Block a user