Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4b7a4a2
refactor(cli): extract sandbox live state helpers
cv May 2, 2026
2ce87dd
refactor(cli): extract sandbox skill install action
cv May 2, 2026
4cd3cf3
refactor(cli): extract sandbox connect action
cv May 3, 2026
e9dd46e
refactor(cli): extract sandbox status action
cv May 3, 2026
aab6c86
refactor(cli): extract sandbox doctor action
cv May 3, 2026
8908521
refactor(cli): extract sandbox destroy action
cv May 3, 2026
56e4f05
refactor(cli): extract sandbox rebuild action
cv May 3, 2026
8bf1958
refactor(cli): extract upgrade sandboxes action
cv May 3, 2026
38eb84d
refactor(cli): remove runtime bridge
cv May 3, 2026
b2ad5da
refactor(cli): remove legacy dispatch fallbacks
cv May 3, 2026
edd2650
refactor(cli): expose explicit main entrypoint
cv May 3, 2026
a15da95
refactor(cli): add oclif examples for utility commands
cv May 3, 2026
4f57ebb
refactor(cli): validate logs flags with oclif
cv May 3, 2026
8b2d077
refactor(cli): improve sandbox diagnostic command metadata
cv May 3, 2026
a09cc51
refactor(cli): tighten policy and channel parser validation
cv May 3, 2026
75857dc
refactor(cli): improve snapshot command metadata
cv May 3, 2026
11c0676
refactor(cli): require skill install path in oclif
cv May 3, 2026
05f9eca
refactor(cli): add lifecycle confirmation flag aliases
cv May 3, 2026
4ebeae4
refactor(cli): split share into oclif subcommands
cv May 3, 2026
7d72437
Revert "refactor(cli): split share into oclif subcommands"
cv May 3, 2026
0ee5ca5
refactor(cli): split share into oclif subcommands
cv May 3, 2026
928219c
refactor(cli): model debug flags with oclif
cv May 3, 2026
36cce5e
refactor(cli): model onboard flags with oclif
cv May 3, 2026
702afb1
docs: sync oclif UX command reference
cv May 3, 2026
3224350
refactor(cli): extract public argv normalizer
cv May 3, 2026
cd4cdb8
refactor(cli): rename oclif dispatch module
cv May 3, 2026
9499ca6
refactor(cli): normalize policy command ids
cv May 3, 2026
42028ef
test(cli): require oclif command metadata
cv May 3, 2026
a05c6b3
refactor(cli): return typed debug parse results
cv May 3, 2026
1875fe9
refactor(cli): add public command display ids
cv May 3, 2026
36f1dbe
refactor(cli): use oclif summaries in root help
cv May 3, 2026
78bfd5a
refactor(cli): table-drive sandbox dispatch
cv May 3, 2026
96ce61f
refactor(cli): normalize gateway token command id
cv May 3, 2026
266ebc9
refactor(cli): render public oclif help
cv May 3, 2026
dc98994
refactor(cli): add shared oclif command base
cv May 3, 2026
d0d2a70
refactor(cli): use oclif flag relationships
cv May 3, 2026
8396c06
refactor(cli): pass lifecycle typed options
cv May 3, 2026
1532b19
refactor(cli): parse durations with oclif flags
cv May 3, 2026
46b349d
merge(main): reconcile duration flag parsing
cv May 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/lib/duration-flags.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from "vitest";

import { parseLogsSinceDuration, parseShieldsTimeoutDuration } from "./duration-flags";

describe("oclif duration flag parsers", () => {
it("normalizes logs --since durations", () => {
expect(parseLogsSinceDuration(" 5m ")).toBe("5m");
expect(parseLogsSinceDuration("30s")).toBe("30s");
});

it("rejects invalid logs --since durations with the public parser message", () => {
expect(() => parseLogsSinceDuration("0s")).toThrow(
"--since requires a positive duration like 5m, 1h, or 30s",
);
expect(() => parseLogsSinceDuration("someday")).toThrow(
"--since requires a positive duration like 5m, 1h, or 30s",
);
});

it("uses the shields duration parser for bounded shields timeouts", () => {
expect(parseShieldsTimeoutDuration(" 5m ")).toBe("5m");
expect(() => parseShieldsTimeoutDuration("2h")).toThrow(/exceeds maximum/);
});
});
35 changes: 35 additions & 0 deletions src/lib/duration-flags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Errors, Flags } from "@oclif/core";

import { parseDuration } from "./duration";

const LOGS_SINCE_DURATION_RE = /^[1-9]\d*(?:ms|s|m|h|d)$/i;

export function parseLogsSinceDuration(input: string): string {
const trimmed = input.trim();
if (!LOGS_SINCE_DURATION_RE.test(trimmed)) {
throw new Errors.CLIError("--since requires a positive duration like 5m, 1h, or 30s");
}
return trimmed;
}

export function parseShieldsTimeoutDuration(input: string): string {
const trimmed = input.trim();
try {
parseDuration(trimmed);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Errors.CLIError(message);
}
return trimmed;
}

export const logsSinceDurationFlag = Flags.custom<string>({
parse: async (input) => parseLogsSinceDuration(input),
});

export const shieldsTimeoutDurationFlag = Flags.custom<string>({
parse: async (input) => parseShieldsTimeoutDuration(input),
});
17 changes: 3 additions & 14 deletions src/lib/sandbox-logs-cli-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { Args, Command, Flags } from "@oclif/core";

import { logsSinceDurationFlag } from "./duration-flags";
import type { SandboxLogsOptions } from "./sandbox-logs-options";
import { DEFAULT_SANDBOX_LOG_LINES } from "./sandbox-logs-options";
import { showSandboxLogs } from "./sandbox-runtime-actions";
Expand All @@ -13,7 +14,6 @@ type SandboxLogsRuntimeBridge = {
sandboxLogs: (sandboxName: string, options: SandboxLogsOptions) => void;
};

const LOGS_SINCE_DURATION_RE = /^[1-9]\d*(?:ms|s|m|h|d)$/i;
const DEFAULT_SANDBOX_LOG_LINE_COUNT = Number(DEFAULT_SANDBOX_LOG_LINES);

let runtimeBridgeFactory = (): SandboxLogsRuntimeBridge => ({ sandboxLogs: showSandboxLogs });
Expand Down Expand Up @@ -56,28 +56,17 @@ export default class SandboxLogsCommand extends Command {
description: "Number of log lines to return",
min: 1,
}),
since: Flags.string({
since: logsSinceDurationFlag({
description: "Only show logs from this duration ago, such as 5m, 1h, or 30s",
}),
};

private normalizeSinceDuration(since: string | undefined): string | null {
if (since === undefined) {
return null;
}
const trimmed = since.trim();
if (!LOGS_SINCE_DURATION_RE.test(trimmed)) {
this.error("--since requires a positive duration like 5m, 1h, or 30s", { exit: 2 });
}
return trimmed;
}

public async run(): Promise<void> {
const { args, flags } = await this.parse(SandboxLogsCommand);
getRuntimeBridge().sandboxLogs(args.sandboxName, {
follow: flags.follow === true,
lines: String(flags.tail),
since: this.normalizeSinceDuration(flags.since),
since: flags.since ?? null,
});
}
}
3 changes: 2 additions & 1 deletion src/lib/shields-cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { Args, Command, Flags } from "@oclif/core";

import { shieldsTimeoutDurationFlag } from "./duration-flags";
import * as shields from "./shields";

const sandboxNameArg = Args.string({
Expand All @@ -23,7 +24,7 @@ export class ShieldsDownCommand extends Command {
static args = { sandboxName: sandboxNameArg };
static flags = {
help: Flags.help({ char: "h" }),
timeout: Flags.string({ description: "Duration before shields are restored" }),
timeout: shieldsTimeoutDurationFlag({ description: "Duration before shields are restored" }),
reason: Flags.string({ description: "Reason for lowering shields" }),
policy: Flags.string({ description: "Policy to apply while shields are down" }),
};
Expand Down
Loading