mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-04-10 17:59:37 +08:00
fix(cli): emit JSON error for unsupported resumed slash commands in JSON mode
When claw --output-format json --resume <session> /commit (or /plugins, etc.)
encountered an 'unsupported resumed slash command' error, it called
eprintln!() and exit(2) directly, bypassing both the main() JSON error
handler and the output_format check.
Fix: in both the slash-command parse-error path and the run_resume_command
Err path, check output_format and emit a structured JSON error:
{"type":"error","error":"unsupported resumed slash command","command":"/commit"}
Text mode unchanged (still exits 2 with prose to stderr).
Addresses the resumed-command parity gap (gaebal-gajae ROADMAP #26 track).
159 CLI tests pass, fmt clean.
This commit is contained in:
parent
84b77ece4d
commit
da4242198f
@ -2217,11 +2217,33 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
|
||||
let command = match SlashCommand::parse(raw_command) {
|
||||
Ok(Some(command)) => command,
|
||||
Ok(None) => {
|
||||
eprintln!("unsupported resumed command: {raw_command}");
|
||||
if output_format == CliOutputFormat::Json {
|
||||
eprintln!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
"type": "error",
|
||||
"error": format!("unsupported resumed command: {raw_command}"),
|
||||
"command": raw_command,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
eprintln!("unsupported resumed command: {raw_command}");
|
||||
}
|
||||
std::process::exit(2);
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("{error}");
|
||||
if output_format == CliOutputFormat::Json {
|
||||
eprintln!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
"type": "error",
|
||||
"error": error.to_string(),
|
||||
"command": raw_command,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
eprintln!("{error}");
|
||||
}
|
||||
std::process::exit(2);
|
||||
}
|
||||
};
|
||||
@ -2247,7 +2269,18 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("{error}");
|
||||
if output_format == CliOutputFormat::Json {
|
||||
eprintln!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
"type": "error",
|
||||
"error": error.to_string(),
|
||||
"command": raw_command,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
eprintln!("{error}");
|
||||
}
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user