diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml index b9019697..73da51c2 100644 --- a/proxmox/Cargo.toml +++ b/proxmox/Cargo.toml @@ -17,6 +17,7 @@ anyhow = "1.0" lazy_static = "1.4" libc = "0.2" nix = "0.19.1" +unicode-width ="0.1.8" # tools module: base32 = { version = "0.4", optional = true } diff --git a/proxmox/src/api/cli/text_table.rs b/proxmox/src/api/cli/text_table.rs index 84d9f346..d1366293 100644 --- a/proxmox/src/api/cli/text_table.rs +++ b/proxmox/src/api/cli/text_table.rs @@ -2,6 +2,7 @@ use std::io::Write; use anyhow::*; use serde_json::Value; +use unicode_width::UnicodeWidthStr; use crate::api::schema::*; @@ -472,7 +473,7 @@ fn format_table( let lines: Vec = text .lines() .map(|line| { - let width = line.chars().count(); + let width = UnicodeWidthStr::width(line); if width > max_width { max_width = width; } @@ -564,10 +565,11 @@ fn render_table( text.push(' '); } + let padding = column.width - UnicodeWidthStr::width(line.as_str()); if column.right_align { - text.push_str(&format!("{:>width$}", line, width = column.width)); + text.push_str(&format!("{:>width$}{}", "", line, width = padding)); } else { - text.push_str(&format!("{: