mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-19 10:51:40 +00:00
14 lines
506 B
TypeScript
14 lines
506 B
TypeScript
// Commander parser for the shared CLI --log-level option.
|
|
import { InvalidArgumentError } from "commander";
|
|
import { ALLOWED_LOG_LEVELS, type LogLevel, tryParseLogLevel } from "../logging/levels.js";
|
|
|
|
export const CLI_LOG_LEVEL_VALUES = ALLOWED_LOG_LEVELS.join("|");
|
|
|
|
export function parseCliLogLevelOption(value: string): LogLevel {
|
|
const parsed = tryParseLogLevel(value);
|
|
if (!parsed) {
|
|
throw new InvalidArgumentError(`Invalid --log-level (use ${CLI_LOG_LEVEL_VALUES})`);
|
|
}
|
|
return parsed;
|
|
}
|