diff --git a/src/format.rs b/src/format.rs index b23b67534..ae43c6f8a 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,4 +1,3 @@ -crate mod consts; crate mod entries; crate mod generic; crate mod list; diff --git a/src/format/consts.rs b/src/format/consts.rs deleted file mode 100644 index c36870da8..000000000 --- a/src/format/consts.rs +++ /dev/null @@ -1,14 +0,0 @@ -use lazy_static::lazy_static; - -use prettytable::format::{FormatBuilder, LinePosition, LineSeparator, TableFormat}; - -lazy_static! { - pub(crate) static ref TABLE_FORMAT: TableFormat = - FormatBuilder::new() - .column_separator('│') - .separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' ')) - .separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' ')) - .separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' ')) - .padding(1, 1) - .build(); -} diff --git a/src/format/table.rs b/src/format/table.rs index db126b9d1..eb6babeae 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -1,9 +1,10 @@ -use crate::format::{RenderView, consts}; +use crate::format::RenderView; use crate::object::Value; use crate::prelude::*; use derive_new::new; use textwrap::fill; +use prettytable::format::{FormatBuilder, LinePosition, LineSeparator}; use prettytable::{color, Attr, Cell, Row, Table}; #[derive(Debug, new)] @@ -49,9 +50,12 @@ impl TableView { } => headers .iter() .enumerate() - .map(|(i, d)| { + .map(|(i, d)| { let data = value.get_data(d); - return (data.borrow().format_leaf(Some(&headers[i])), data.borrow().style_leaf()); + return ( + data.borrow().format_leaf(Some(&headers[i])), + data.borrow().style_leaf(), + ); }) .collect(), x => vec![(x.format_leaf(None), x.style_leaf())], @@ -191,7 +195,15 @@ impl RenderView for TableView { } let mut table = Table::new(); - table.set_format(*consts::TABLE_FORMAT); + table.set_format( + FormatBuilder::new() + .column_separator('│') + .separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' ')) + .separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' ')) + .separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' ')) + .padding(1, 1) + .build(), + ); let header: Vec = self .headers @@ -206,7 +218,11 @@ impl RenderView for TableView { table.set_titles(Row::new(header)); for row in &self.entries { - table.add_row(Row::new(row.iter().map(|(v, s)| Cell::new(v).style_spec(s)).collect())); + table.add_row(Row::new( + row.iter() + .map(|(v, s)| Cell::new(v).style_spec(s)) + .collect(), + )); } table.print_term(&mut *host.out_terminal()).unwrap(); diff --git a/src/format/vtable.rs b/src/format/vtable.rs index 533baea8b..08c4a72d0 100644 --- a/src/format/vtable.rs +++ b/src/format/vtable.rs @@ -1,8 +1,9 @@ -use crate::format::{RenderView, consts}; +use crate::format::RenderView; use crate::object::Value; use crate::prelude::*; use derive_new::new; +use prettytable::format::{FormatBuilder, LinePosition, LineSeparator}; use prettytable::{color, Attr, Cell, Row, Table}; #[derive(new)] @@ -46,7 +47,15 @@ impl RenderView for VTableView { } let mut table = Table::new(); - table.set_format(*consts::TABLE_FORMAT); + table.set_format( + FormatBuilder::new() + .column_separator('│') + .separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' ')) + .separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' ')) + .separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' ')) + .padding(1, 1) + .build(), + ); for row in &self.entries { table.add_row(Row::new(