From 033cae2464913d46d997d9b1953396d35b0a03f9 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 26 Aug 2019 18:42:14 +1200 Subject: [PATCH] Fix the build --- src/format.rs | 1 - src/format/consts.rs | 14 -------------- src/format/table.rs | 26 +++++++++++++++++++++----- src/format/vtable.rs | 13 +++++++++++-- 4 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 src/format/consts.rs diff --git a/src/format.rs b/src/format.rs index b23b67534e..ae43c6f8a9 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 c36870da8f..0000000000 --- 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 db126b9d1b..eb6babeae7 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 533baea8b2..08c4a72d0d 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(