mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-09 17:44:50 +08:00
fix(cli): validate --reasoning-effort accepts only low|medium|high
Previously any string was accepted and silently forwarded to the API, which would fail at the provider with an unhelpful error. Now invalid values produce a clear error at parse time: invalid value for --reasoning-effort: 'xyz'; must be low, medium, or high 156 CLI tests pass, fmt clean.
This commit is contained in:
@@ -476,11 +476,22 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
||||
let value = args
|
||||
.get(index + 1)
|
||||
.ok_or_else(|| "missing value for --reasoning-effort".to_string())?;
|
||||
if !matches!(value.as_str(), "low" | "medium" | "high") {
|
||||
return Err(format!(
|
||||
"invalid value for --reasoning-effort: '{value}'; must be low, medium, or high"
|
||||
));
|
||||
}
|
||||
reasoning_effort = Some(value.clone());
|
||||
index += 2;
|
||||
}
|
||||
flag if flag.starts_with("--reasoning-effort=") => {
|
||||
reasoning_effort = Some(flag[19..].to_string());
|
||||
let value = &flag[19..];
|
||||
if !matches!(value, "low" | "medium" | "high") {
|
||||
return Err(format!(
|
||||
"invalid value for --reasoning-effort: '{value}'; must be low, medium, or high"
|
||||
));
|
||||
}
|
||||
reasoning_effort = Some(value.to_string());
|
||||
index += 1;
|
||||
}
|
||||
"-p" => {
|
||||
|
||||
Reference in New Issue
Block a user