From f68d655fb81358c524cec8f605054559facec378 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Sat, 7 Aug 2021 00:10:24 +0800 Subject: [PATCH] [fix] pretty print Signed-off-by: Chojan Shang --- common/datablocks/src/data_block_debug.rs | 2 +- common/datavalues/src/series/series_debug.rs | 2 +- fusecli/cli/src/cmds/packages/list.rs | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/datablocks/src/data_block_debug.rs b/common/datablocks/src/data_block_debug.rs index 242a607758072..a0120aba7bf2c 100644 --- a/common/datablocks/src/data_block_debug.rs +++ b/common/datablocks/src/data_block_debug.rs @@ -10,7 +10,7 @@ use crate::DataBlock; ///! Create a visual representation of record batches pub fn pretty_format_blocks(results: &[DataBlock]) -> Result { - Ok(create_table(results)?.to_string()) + Ok(create_table(results)?.trim_fmt()) } pub fn assert_blocks_eq(expect: Vec<&str>, blocks: &[DataBlock]) { diff --git a/common/datavalues/src/series/series_debug.rs b/common/datavalues/src/series/series_debug.rs index c34a9b93513de..52ddec3362aaa 100644 --- a/common/datavalues/src/series/series_debug.rs +++ b/common/datavalues/src/series/series_debug.rs @@ -10,7 +10,7 @@ use super::Series; ///! Create a visual representation of record batches pub fn pretty_format_series(results: &[Series]) -> Result { - Ok(create_table(results)?.to_string()) + Ok(create_table(results)?.trim_fmt()) } pub fn assert_series_eq(expect: Vec<&str>, series: &[Series]) { diff --git a/fusecli/cli/src/cmds/packages/list.rs b/fusecli/cli/src/cmds/packages/list.rs index 054e97a52ea5c..0697e0d985b3d 100644 --- a/fusecli/cli/src/cmds/packages/list.rs +++ b/fusecli/cli/src/cmds/packages/list.rs @@ -4,8 +4,9 @@ use std::fs; -use colored::Colorize; use comfy_table::Cell; +use comfy_table::CellAlignment; +use comfy_table::Color; use comfy_table::Table; use crate::cmds::Config; @@ -51,16 +52,16 @@ impl ListCommand { .into_owned(); let mut row = vec![]; row.push(Cell::new(version.as_str())); - row.push(Cell::new(format!("{}", path.path().display(),).as_str())); + row.push(Cell::new(path.path().display())); - let mut current_marker = "".to_string(); + let mut current_marker = Cell::new(""); if current == version { - current_marker = format!("{}", "✅ ".blue()); + current_marker = Cell::new("☑").fg(Color::Green); } - row.push(Cell::new(current_marker.as_str())); + row.push(current_marker.set_alignment(CellAlignment::Center)); table.add_row(row); } - writer.writeln(&table.to_string()); + writer.writeln(&table.trim_fmt()); Ok(()) }