fix(client): truncate long commands and output in log lines (max 60 chars)
This commit is contained in:
parent
ccf585f801
commit
ef4ca0ccbb
1 changed files with 15 additions and 4 deletions
|
|
@ -320,15 +320,26 @@ async fn handle_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::ExecRequest { request_id, command } => {
|
ServerMessage::ExecRequest { request_id, command } => {
|
||||||
log_cmd!("exec › {}", command);
|
// Truncate long commands for display
|
||||||
|
let cmd_display = if command.len() > 60 {
|
||||||
|
format!("{}…", &command[..60])
|
||||||
|
} else {
|
||||||
|
command.clone()
|
||||||
|
};
|
||||||
|
log_cmd!("exec › {}", cmd_display);
|
||||||
let mut sh = shell.lock().await;
|
let mut sh = shell.lock().await;
|
||||||
match sh.run(&command).await {
|
match sh.run(&command).await {
|
||||||
Ok((stdout, stderr, exit_code)) => {
|
Ok((stdout, stderr, exit_code)) => {
|
||||||
let out = stdout.trim().lines().next().unwrap_or("").to_string();
|
let out = stdout.trim().lines().next().unwrap_or("").to_string();
|
||||||
if out.is_empty() {
|
let out_display = if out.len() > 60 {
|
||||||
log_ok!("Done {} exit {}", "·".dimmed(), exit_code);
|
format!("{}…", &out[..60])
|
||||||
} else {
|
} else {
|
||||||
log_ok!("{} {} exit {}", out, "·".dimmed(), exit_code);
|
out
|
||||||
|
};
|
||||||
|
if out_display.is_empty() {
|
||||||
|
log_ok!("exit {}", exit_code);
|
||||||
|
} else {
|
||||||
|
log_ok!("{} {} exit {}", out_display, "·".dimmed(), exit_code);
|
||||||
}
|
}
|
||||||
let _ = stderr;
|
let _ = stderr;
|
||||||
ClientMessage::ExecResponse {
|
ClientMessage::ExecResponse {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue