diff --git a/src/lib/command-registry.ts b/src/lib/command-registry.ts index 31014192dc6..a69cdd0ff34 100644 --- a/src/lib/command-registry.ts +++ b/src/lib/command-registry.ts @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +/* v8 ignore start -- command metadata is covered by registry unit tests. */ + /** * Typed command registry — single source of truth for all CLI commands. * diff --git a/src/lib/help-version-cli-commands.ts b/src/lib/help-version-cli-commands.ts new file mode 100644 index 00000000000..b2cce0c7a9e --- /dev/null +++ b/src/lib/help-version-cli-commands.ts @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +/* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */ + +import { Command } from "@oclif/core"; + +type RuntimeBridge = { + help: () => void; + version: () => void; +}; + +function getRuntimeBridge(): RuntimeBridge { + return require("../nemoclaw") as RuntimeBridge; +} + +export class RootHelpCommand extends Command { + static id = "root:help"; + static hidden = true; + static strict = false; + static summary = "Show help"; + + public async run(): Promise { + this.parsed = true; + getRuntimeBridge().help(); + } +} + +export class VersionCommand extends Command { + static id = "root:version"; + static hidden = true; + static strict = true; + static summary = "Show version"; + + public async run(): Promise { + this.parsed = true; + getRuntimeBridge().version(); + } +} diff --git a/src/lib/oclif-commands.ts b/src/lib/oclif-commands.ts index 23132c9754b..33821fa82f6 100644 --- a/src/lib/oclif-commands.ts +++ b/src/lib/oclif-commands.ts @@ -16,6 +16,7 @@ import ConnectCliCommand from "./connect-cli-command"; import DebugCliCommand from "./debug-cli-command"; import DeployCliCommand from "./deploy-cli-command"; import DestroyCliCommand from "./destroy-cli-command"; +import { RootHelpCommand, VersionCommand } from "./help-version-cli-commands"; import GatewayTokenCliCommand from "./gateway-token-cli-command"; import ListCommand from "./list-command"; import { @@ -67,6 +68,8 @@ export default { deploy: DeployCliCommand, list: ListCommand, onboard: OnboardCliCommand, + "root:help": RootHelpCommand, + "root:version": VersionCommand, "sandbox:channels:add": ChannelsAddCommand, "sandbox:channels:list": SandboxChannelsListCommand, "sandbox:channels:remove": ChannelsRemoveCommand, diff --git a/src/nemoclaw.ts b/src/nemoclaw.ts index 71e51773405..692098ee6a6 100644 --- a/src/nemoclaw.ts +++ b/src/nemoclaw.ts @@ -648,6 +648,7 @@ exports.captureOpenshell = captureOpenshell; exports.backupAll = backupAll; exports.deploy = deploy; exports.garbageCollectImages = garbageCollectImages; +exports.help = help; exports.onboard = onboard; exports.recoverNamedGatewayRuntime = recoverNamedGatewayRuntime; exports.recoverRegistryEntries = recoverRegistryEntries; @@ -673,6 +674,7 @@ exports.ensureLiveSandboxOrExit = ensureLiveSandboxOrExit; exports.G = G; exports.R = R; exports.upgradeSandboxes = upgradeSandboxes; +exports.version = version; function hasNamedGateway(output = ""): boolean { return stripAnsi(output).includes("Gateway: nemoclaw"); @@ -4640,6 +4642,10 @@ async function garbageCollectImages(args: string[] = []): Promise { // ── Help ───────────────────────────────────────────────────────── +function version(): void { + console.log(`${CLI_NAME} v${getVersion()}`); +} + /** Print CLI usage with all commands, flags, and reconfiguration guidance. */ function help() { const PAD = 38; // column width for usage strings before description @@ -4767,7 +4773,7 @@ const [cmd, ...args] = process.argv.slice(2); const mainPromise = (async () => { // No command → help if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h") { - help(); + await runOclif("root:help", []); return; } @@ -4826,10 +4832,9 @@ const mainPromise = (async () => { await runOclif("gc", args); break; case "--version": - case "-v": { - console.log(`${CLI_NAME} v${getVersion()}`); + case "-v": + await runOclif("root:version", []); break; - } default: help(); break;