diff --git a/src/lib/list-command.ts b/src/lib/list-command.ts index c7be5f7fbee..8117fbe11fd 100644 --- a/src/lib/list-command.ts +++ b/src/lib/list-command.ts @@ -3,12 +3,11 @@ /* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */ -import { Command, Flags } from "@oclif/core"; - import { getSandboxInventory, renderSandboxInventoryText } from "./inventory-commands"; +import { NemoClawCommand } from "./nemoclaw-oclif-command"; import { buildListCommandDeps } from "./list-command-deps"; -export default class ListCommand extends Command { +export default class ListCommand extends NemoClawCommand { static id = "list"; static strict = true; static enableJsonFlag = true; @@ -17,13 +16,7 @@ export default class ListCommand extends Command { "List all registered sandboxes with their model, provider, and policy presets."; static usage = ["list [--json]"]; static examples = ["<%= config.bin %> list", "<%= config.bin %> list --json"]; - static flags = { - help: Flags.help({ char: "h" }), - }; - - protected logJson(json: unknown): void { - console.log(JSON.stringify(json, null, 2)); - } + static flags = {}; public async run(): Promise { await this.parse(ListCommand); diff --git a/src/lib/maintenance-cli-commands.ts b/src/lib/maintenance-cli-commands.ts index 62b22601071..d1d5d75224f 100644 --- a/src/lib/maintenance-cli-commands.ts +++ b/src/lib/maintenance-cli-commands.ts @@ -3,24 +3,23 @@ /* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */ -import { Command, Flags } from "@oclif/core"; +import { Flags } from "@oclif/core"; import { runBackupAllAction, runGarbageCollectImagesAction, runUpgradeSandboxesAction, } from "./global-cli-actions"; +import { NemoClawCommand } from "./nemoclaw-oclif-command"; -export class BackupAllCommand extends Command { +export class BackupAllCommand extends NemoClawCommand { static id = "backup-all"; static strict = true; static summary = "Back up all sandbox state before upgrade"; static description = "Back up registered, running sandbox state before upgrading."; static usage = ["backup-all"]; static examples = ["<%= config.bin %> backup-all"]; - static flags = { - help: Flags.help({ char: "h" }), - }; + static flags = {}; public async run(): Promise { await this.parse(BackupAllCommand); @@ -28,7 +27,7 @@ export class BackupAllCommand extends Command { } } -export class UpgradeSandboxesCommand extends Command { +export class UpgradeSandboxesCommand extends NemoClawCommand { static id = "upgrade-sandboxes"; static strict = true; static summary = "Detect and rebuild stale sandboxes"; @@ -39,7 +38,6 @@ export class UpgradeSandboxesCommand extends Command { "<%= config.bin %> upgrade-sandboxes --auto --yes", ]; static flags = { - help: Flags.help({ char: "h" }), check: Flags.boolean({ description: "Only check whether sandboxes need upgrading" }), auto: Flags.boolean({ description: "Automatically rebuild running stale sandboxes" }), yes: Flags.boolean({ char: "y", description: "Skip confirmation prompts" }), @@ -55,7 +53,7 @@ export class UpgradeSandboxesCommand extends Command { } } -export class GarbageCollectImagesCommand extends Command { +export class GarbageCollectImagesCommand extends NemoClawCommand { static id = "gc"; static strict = true; static summary = "Remove orphaned sandbox Docker images"; @@ -63,7 +61,6 @@ export class GarbageCollectImagesCommand extends Command { static usage = ["gc [--dry-run] [--yes|-y|--force]"]; static examples = ["<%= config.bin %> gc --dry-run", "<%= config.bin %> gc --yes"]; static flags = { - help: Flags.help({ char: "h" }), "dry-run": Flags.boolean({ description: "Show images that would be removed without deleting" }), yes: Flags.boolean({ char: "y", description: "Skip the confirmation prompt" }), force: Flags.boolean({ description: "Skip the confirmation prompt" }), diff --git a/src/lib/nemoclaw-oclif-command.ts b/src/lib/nemoclaw-oclif-command.ts new file mode 100644 index 00000000000..fd7dda76f30 --- /dev/null +++ b/src/lib/nemoclaw-oclif-command.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { Command, Flags } from "@oclif/core"; + +/** + * Shared oclif base for NemoClaw commands. + * + * Keep CLI-wide parser conventions here so individual command classes only + * describe their own grammar. + */ +export abstract class NemoClawCommand extends Command { + static baseFlags = { + help: Flags.help({ char: "h" }), + }; + + protected logJson(json: unknown): void { + console.log(JSON.stringify(json, null, 2)); + } +} diff --git a/src/lib/status-command.ts b/src/lib/status-command.ts index 956c4647a85..cc2dc3e822f 100644 --- a/src/lib/status-command.ts +++ b/src/lib/status-command.ts @@ -3,12 +3,11 @@ /* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */ -import { Command, Flags } from "@oclif/core"; - import { getStatusReport, showStatusCommand } from "./inventory-commands"; +import { NemoClawCommand } from "./nemoclaw-oclif-command"; import { buildStatusCommandDeps } from "./status-command-deps"; -export default class StatusCommand extends Command { +export default class StatusCommand extends NemoClawCommand { static id = "status"; static strict = true; static enableJsonFlag = true; @@ -16,13 +15,7 @@ export default class StatusCommand extends Command { static description = "Show registered sandboxes, live inference, services, and messaging health."; static usage = ["status [--json]"]; static examples = ["<%= config.bin %> status", "<%= config.bin %> status --json"]; - static flags = { - help: Flags.help({ char: "h" }), - }; - - protected logJson(json: unknown): void { - console.log(JSON.stringify(json, null, 2)); - } + static flags = {}; public async run(): Promise { await this.parse(StatusCommand);