nu-table: Don't show empty header (#6035)
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
parent
ad9449bf00
commit
f2a79cf381
|
@ -167,11 +167,7 @@ impl Command for Table {
|
|||
])
|
||||
}
|
||||
|
||||
let table = nu_table::Table {
|
||||
headers: None,
|
||||
data: output,
|
||||
theme: load_theme_from_config(config),
|
||||
};
|
||||
let table = nu_table::Table::new(None, output, load_theme_from_config(config));
|
||||
|
||||
let result = nu_table::draw_table(&table, term_width, &color_hm, config)
|
||||
.unwrap_or_else(|| format!("Couldn't fit table into {} columns!", term_width));
|
||||
|
@ -429,8 +425,8 @@ fn convert_to_table(
|
|||
data.push(row);
|
||||
}
|
||||
|
||||
Ok(Some(nu_table::Table {
|
||||
headers: Some(
|
||||
Ok(Some(nu_table::Table::new(
|
||||
Some(
|
||||
headers
|
||||
.into_iter()
|
||||
.map(|x| StyledString {
|
||||
|
@ -442,8 +438,7 @@ fn convert_to_table(
|
|||
})
|
||||
.collect(),
|
||||
),
|
||||
data: data
|
||||
.into_iter()
|
||||
data.into_iter()
|
||||
.map(|x| {
|
||||
x.into_iter()
|
||||
.enumerate()
|
||||
|
@ -477,8 +472,8 @@ fn convert_to_table(
|
|||
.collect::<Vec<StyledString>>()
|
||||
})
|
||||
.collect(),
|
||||
theme: load_theme_from_config(config),
|
||||
}))
|
||||
load_theme_from_config(config),
|
||||
)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ use crate::{
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Table {
|
||||
pub headers: Option<Vec<StyledString>>,
|
||||
pub data: Vec<Vec<StyledString>>,
|
||||
pub theme: TableTheme,
|
||||
headers: Option<Vec<StyledString>>,
|
||||
data: Vec<Vec<StyledString>>,
|
||||
theme: TableTheme,
|
||||
}
|
||||
|
||||
impl Table {
|
||||
|
@ -30,6 +30,11 @@ impl Table {
|
|||
data: Vec<Vec<StyledString>>,
|
||||
theme: TableTheme,
|
||||
) -> Table {
|
||||
let headers = match headers {
|
||||
Some(headers) if headers.is_empty() => None,
|
||||
headers => headers,
|
||||
};
|
||||
|
||||
Table {
|
||||
headers,
|
||||
data,
|
||||
|
|
Loading…
Reference in New Issue
Block a user