refactor(update-cli): share timeout option validation

This commit is contained in:
Peter Steinberger
2026-02-18 22:49:15 +00:00
parent b704bad8f3
commit 61c0c147ad
5 changed files with 42 additions and 14 deletions

View File

@@ -37,6 +37,18 @@ export type UpdateWizardOptions = {
timeout?: string;
};
const INVALID_TIMEOUT_ERROR = "--timeout must be a positive integer (seconds)";
export function parseTimeoutMsOrExit(timeout?: string): number | undefined | null {
const timeoutMs = timeout ? Number.parseInt(timeout, 10) * 1000 : undefined;
if (timeoutMs !== undefined && (Number.isNaN(timeoutMs) || timeoutMs <= 0)) {
defaultRuntime.error(INVALID_TIMEOUT_ERROR);
defaultRuntime.exit(1);
return null;
}
return timeoutMs;
}
const OPENCLAW_REPO_URL = "https://github.com/openclaw/openclaw.git";
const MAX_LOG_CHARS = 8000;