mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:25:38 +02:00
Refactoring nu_table (#6049)
* nu-table: Remove unused dependencies Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Small refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Refactoring alignments Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add width check Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Use commit instead of branch of tabled To be safe * Update Cargo.lock Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
@ -7,7 +7,7 @@ use nu_protocol::{
|
||||
format_error, Category, Config, DataSource, Example, IntoPipelineData, ListStream,
|
||||
PipelineData, PipelineMetadata, RawStream, ShellError, Signature, Span, SyntaxShape, Value,
|
||||
};
|
||||
use nu_table::{StyledString, TableTheme, TextStyle};
|
||||
use nu_table::{Alignments, StyledString, TableTheme, TextStyle};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
@ -167,9 +167,11 @@ impl Command for Table {
|
||||
])
|
||||
}
|
||||
|
||||
let table = nu_table::Table::new(None, output, load_theme_from_config(config));
|
||||
let table =
|
||||
nu_table::Table::new(Vec::new(), output, load_theme_from_config(config));
|
||||
|
||||
let result = nu_table::draw_table(&table, term_width, &color_hm, config)
|
||||
let result = table
|
||||
.draw_table(config, &color_hm, Alignments::default(), term_width)
|
||||
.unwrap_or_else(|| format!("Couldn't fit table into {} columns!", term_width));
|
||||
|
||||
Ok(Value::String {
|
||||
@ -426,18 +428,16 @@ fn convert_to_table(
|
||||
}
|
||||
|
||||
Ok(Some(nu_table::Table::new(
|
||||
Some(
|
||||
headers
|
||||
.into_iter()
|
||||
.map(|x| StyledString {
|
||||
contents: x,
|
||||
style: TextStyle {
|
||||
alignment: nu_table::Alignment::Center,
|
||||
color_style: Some(color_hm["header"]),
|
||||
},
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
headers
|
||||
.into_iter()
|
||||
.map(|x| StyledString {
|
||||
contents: x,
|
||||
style: TextStyle {
|
||||
alignment: nu_table::Alignment::Center,
|
||||
color_style: Some(color_hm["header"]),
|
||||
},
|
||||
})
|
||||
.collect(),
|
||||
data.into_iter()
|
||||
.map(|x| {
|
||||
x.into_iter()
|
||||
@ -554,7 +554,8 @@ impl Iterator for PagingTableCreator {
|
||||
|
||||
match table {
|
||||
Ok(Some(table)) => {
|
||||
let result = nu_table::draw_table(&table, term_width, &color_hm, &self.config)
|
||||
let result = table
|
||||
.draw_table(&self.config, &color_hm, Alignments::default(), term_width)
|
||||
.unwrap_or_else(|| format!("Couldn't fit table into {} columns!", term_width));
|
||||
|
||||
Some(Ok(result.as_bytes().to_vec()))
|
||||
|
Reference in New Issue
Block a user