fix: header alignment, 🪪 session, commit-only version, clipboard shows text, no extra blank lines
This commit is contained in:
parent
05a63fe911
commit
20cae0b717
2 changed files with 9 additions and 11 deletions
|
|
@ -96,10 +96,10 @@ pub fn cmd_done(action: &str, name: &str, payload: &str, success: bool, result:
|
||||||
crate::logger::write_line(if success { "OK" } else { "ERROR" }, &format!("{name} {payload} → {result}"));
|
crate::logger::write_line(if success { "OK" } else { "ERROR" }, &format!("{name} {payload} → {result}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Info line for the startup header (not in table format).
|
/// Info line for the startup header — uses same column alignment as table rows.
|
||||||
/// Aligns key to a fixed width so values line up.
|
|
||||||
pub fn info_line(emoji: &str, key: &str, value: &str) {
|
pub fn info_line(emoji: &str, key: &str, value: &str) {
|
||||||
println!(" {} {:<12} {}", emoji_cell(emoji), key, value);
|
// Match table layout: 2 spaces + 2-wide emoji + 2 spaces + name (NAME_W) + 2 spaces + value
|
||||||
|
println!(" {} {:<name_w$} {}", emoji_cell(emoji), key, value, name_w = NAME_W);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn err(emoji: &str, msg: &str) {
|
pub fn err(emoji: &str, msg: &str) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use display::trunc;
|
||||||
|
|
||||||
fn banner() {
|
fn banner() {
|
||||||
println!();
|
println!();
|
||||||
println!(" {} HELIOS REMOTE ({})", "☀".yellow().bold(), env!("GIT_COMMIT"));
|
println!(" {} HELIOS REMOTE {}", "☀".yellow().bold(), env!("GIT_COMMIT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
||||||
|
|
@ -43,8 +43,7 @@ fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
||||||
display::info_line("👤", "privileges:", &"no admin".yellow().to_string());
|
display::info_line("👤", "privileges:", &"no admin".yellow().to_string());
|
||||||
|
|
||||||
display::info_line("🖥", "device:", &label.bold().to_string());
|
display::info_line("🖥", "device:", &label.bold().to_string());
|
||||||
display::info_line("#", "session:", &sid.to_string().dimmed().to_string());
|
display::info_line("🪪", "session:", &sid.to_string().dimmed().to_string());
|
||||||
println!();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
@ -218,7 +217,6 @@ async fn main() {
|
||||||
match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await {
|
match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await {
|
||||||
Ok((ws_stream, _)) => {
|
Ok((ws_stream, _)) => {
|
||||||
display::cmd_done("🌐", "connecting", host, true, "connected");
|
display::cmd_done("🌐", "connecting", host, true, "connected");
|
||||||
println!();
|
|
||||||
backoff = Duration::from_secs(1);
|
backoff = Duration::from_secs(1);
|
||||||
|
|
||||||
let (mut write, mut read) = ws_stream.split();
|
let (mut write, mut read) = ws_stream.split();
|
||||||
|
|
@ -505,7 +503,7 @@ async fn handle_message(
|
||||||
display::cmd_start("ℹ", "version", "");
|
display::cmd_start("ℹ", "version", "");
|
||||||
let version = env!("CARGO_PKG_VERSION").to_string();
|
let version = env!("CARGO_PKG_VERSION").to_string();
|
||||||
let commit = env!("GIT_COMMIT").to_string();
|
let commit = env!("GIT_COMMIT").to_string();
|
||||||
display::cmd_done("ℹ", "version", "", true, &format!("v{version} ({commit})"));
|
display::cmd_done("ℹ", "version", "", true, &commit);
|
||||||
ClientMessage::VersionResponse { request_id, version, commit }
|
ClientMessage::VersionResponse { request_id, version, commit }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -584,7 +582,7 @@ async fn handle_message(
|
||||||
match out {
|
match out {
|
||||||
Ok(o) => {
|
Ok(o) => {
|
||||||
let text = String::from_utf8_lossy(&o.stdout).trim().to_string();
|
let text = String::from_utf8_lossy(&o.stdout).trim().to_string();
|
||||||
display::cmd_done("📋", "clipboard-get", "", true, &format!("{} chars", text.len()));
|
display::cmd_done("📋", "clipboard-get", "", true, &text);
|
||||||
ClientMessage::ClipboardGetResponse { request_id, text }
|
ClientMessage::ClipboardGetResponse { request_id, text }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
@ -595,7 +593,7 @@ async fn handle_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::ClipboardSetRequest { request_id, text } => {
|
ServerMessage::ClipboardSetRequest { request_id, text } => {
|
||||||
let payload = format!("{} chars", text.len());
|
let payload = trunc(&text, 60);
|
||||||
display::cmd_start("📋", "clipboard-set", &payload);
|
display::cmd_start("📋", "clipboard-set", &payload);
|
||||||
let cmd = format!("Set-Clipboard -Value '{}'", text.replace('\'', "''"));
|
let cmd = format!("Set-Clipboard -Value '{}'", text.replace('\'', "''"));
|
||||||
let out = tokio::process::Command::new("powershell.exe")
|
let out = tokio::process::Command::new("powershell.exe")
|
||||||
|
|
@ -603,7 +601,7 @@ async fn handle_message(
|
||||||
.output().await;
|
.output().await;
|
||||||
match out {
|
match out {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
display::cmd_done("📋", "clipboard-set", &payload, true, "done");
|
display::cmd_done("📋", "clipboard-set", &payload, true, &payload);
|
||||||
ClientMessage::Ack { request_id }
|
ClientMessage::Ack { request_id }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue