docs: document cli program helpers · openclaw/openclaw@98187f3
steipete
·
2026-06-04
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Root Commander help, global options, banner, version, and example formatting. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | import { formatDocsLink } from "../../../packages/terminal-core/src/links.js"; |
3 | 4 | import { isRich, theme } from "../../../packages/terminal-core/src/theme.js"; |
@@ -92,6 +93,7 @@ export function configureProgramHelp(
|
92 | 93 | }); |
93 | 94 | |
94 | 95 | const formatHelpOutput = (str: string) => { |
| 96 | +// Commander emits plain section labels; decorate them after command-specific help renders. |
95 | 97 | let output = str; |
96 | 98 | const isRootHelp = new RegExp( |
97 | 99 | `^Usage:\\s+${CLI_NAME_PATTERN}\\s+\\[options\\]\\s+\\[command\\]\\s*$`, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Parent-command default action helper that prints help with success exit status. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | |
3 | 4 | const parentDefaultHelpCommands = new WeakSet<Command>(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Commander registration for onboard setup flags and lazy onboard runtime execution. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | import { formatDocsLink } from "../../../packages/terminal-core/src/links.js"; |
3 | 4 | import { theme } from "../../../packages/terminal-core/src/theme.js"; |
@@ -63,6 +64,7 @@ function extractCliFlags(cliOption: string): string[] {
|
63 | 64 | } |
64 | 65 | |
65 | 66 | function resolveOnboardAuthFlags(): OnboardAuthFlag[] { |
| 67 | +// Provider manifests can add auth flags; keep duplicate CLI aliases out of Commander. |
66 | 68 | const seenCliFlags = new Set<string>(); |
67 | 69 | const flags: OnboardAuthFlag[] = []; |
68 | 70 | for (const flag of [...CORE_ONBOARD_AUTH_FLAGS, ...resolveManifestProviderOnboardAuthFlags()]) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Sub-CLI registry that lazily wires gateway, models, devices, plugins, and plugin commands. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | import { createLazyImportLoader } from "../../shared/lazy-promise.js"; |
3 | 4 | import { resolveCliArgvInvocation } from "../argv-invocation.js"; |
@@ -53,6 +54,7 @@ function shouldRegisterGatewayRunOnly(name: string, argv: string[]): boolean {
|
53 | 54 | } |
54 | 55 | |
55 | 56 | async function registerGatewayRunOnly(program: Command): Promise<void> { |
| 57 | +// Hot path for `gateway run`: avoid loading the full gateway command tree. |
56 | 58 | const { addGatewayRunCommand } = await import("../gateway-cli/run-command.js"); |
57 | 59 | removeCommandByName(program, "gateway"); |
58 | 60 | const gateway = addGatewayRunCommand( |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Small interactive prompt helpers for CLI confirmations. |
1 | 2 | import { stdin as input, stdout as output } from "node:process"; |
2 | 3 | import readline from "node:readline/promises"; |
3 | 4 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Debug proxy runtime commands for capture sessions, validation, coverage, and blob reads. |
1 | 2 | import { spawn } from "node:child_process"; |
2 | 3 | import { randomUUID } from "node:crypto"; |
3 | 4 | import process from "node:process"; |
@@ -70,6 +71,7 @@ export async function runDebugProxyRunCommand(opts: {
|
70 | 71 | port?: number; |
71 | 72 | commandArgs: string[]; |
72 | 73 | }) { |
| 74 | +// Each proxied child command gets its own capture session id for later query/filtering. |
73 | 75 | if (opts.commandArgs.length === 0) { |
74 | 76 | throw new Error("proxy run requires a command after --"); |
75 | 77 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Commander registration for debug proxy capture, validation, query, and blob commands. |
1 | 2 | import { InvalidArgumentError, type Command } from "commander"; |
2 | 3 | import { parseStrictInteger } from "../infra/parse-finite-number.js"; |
3 | 4 | import type { CaptureQueryPreset } from "../proxy-capture/types.js"; |
@@ -10,6 +11,7 @@ const proxyCliRuntimeLoader = createLazyImportLoader<ProxyCliRuntime>(
|
10 | 11 | ); |
11 | 12 | |
12 | 13 | async function loadProxyCliRuntime(): Promise<ProxyCliRuntime> { |
| 14 | +// Keep proxy CA/server/sqlite dependencies out of normal CLI startup. |
13 | 15 | return await proxyCliRuntimeLoader.load(); |
14 | 16 | } |
15 | 17 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// QR/setup-code CLI for mobile/device pairing with local or remote Gateway credentials. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | import { formatDocsLink } from "../../packages/terminal-core/src/links.js"; |
3 | 4 | import { theme } from "../../packages/terminal-core/src/theme.js"; |
@@ -40,6 +41,7 @@ function shouldResolveLocalGatewayPasswordSecret(
|
40 | 41 | cfg: OpenClawConfig, |
41 | 42 | env: NodeJS.ProcessEnv, |
42 | 43 | ): boolean { |
| 44 | +// Default/implicit password auth may require resolving a local SecretRef before encoding setup. |
43 | 45 | if (trimToUndefined(env.OPENCLAW_GATEWAY_PASSWORD)) { |
44 | 46 | return false; |
45 | 47 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// CLI respawn skip policy for help, interactive TTY commands, and foreground Gateway runs. |
1 | 2 | import { resolveCliArgvInvocation } from "./argv-invocation.js"; |
2 | 3 | import { getCommandPositionalsWithRootOptions } from "./argv.js"; |
3 | 4 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Cached startup metadata readers for precomputed root and subcommand help text. |
1 | 2 | import { readCliStartupMetadata } from "./startup-metadata.js"; |
2 | 3 | |
3 | 4 | export type PrecomputedSubcommandHelpName = "doctor" | "gateway" | "models" | "plugins"; |
@@ -21,6 +22,7 @@ function loadPrecomputedHelpText(
|
21 | 22 | cache: string | null | undefined, |
22 | 23 | setCache: (value: string | null) => void, |
23 | 24 | ): string | null { |
| 25 | +// Missing metadata is expected in source checkouts; fall back to live Commander help. |
24 | 26 | if (cache !== undefined) { |
25 | 27 | return cache; |
26 | 28 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。