mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 00:35:01 +02:00
add optional footer to table (#392)
* add optional footer to table * missed a draw_table
This commit is contained in:
@ -9,6 +9,7 @@ pub struct Config {
|
||||
pub use_ls_colors: bool,
|
||||
pub color_config: HashMap<String, String>,
|
||||
pub use_grid_icons: bool,
|
||||
pub footer_mode: FooterMode,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -19,10 +20,23 @@ impl Default for Config {
|
||||
use_ls_colors: true,
|
||||
color_config: HashMap::new(),
|
||||
use_grid_icons: false,
|
||||
footer_mode: FooterMode::Never,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub enum FooterMode {
|
||||
/// Never show the footer
|
||||
Never,
|
||||
/// Always show the footer
|
||||
Always,
|
||||
/// Only show the footer if there are more than RowCount rows
|
||||
RowCount(u64),
|
||||
/// Calculate the screen height, calculate row count, if display will be bigger than screen, add the footer
|
||||
Auto,
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn into_config(self) -> Result<Config, ShellError> {
|
||||
let v = self.as_record()?;
|
||||
@ -51,6 +65,18 @@ impl Value {
|
||||
"use_grid_icons" => {
|
||||
config.use_grid_icons = value.as_bool()?;
|
||||
}
|
||||
"footer_mode" => {
|
||||
let val_str = value.as_string()?;
|
||||
config.footer_mode = match val_str.as_ref() {
|
||||
"auto" => FooterMode::Auto,
|
||||
"never" => FooterMode::Never,
|
||||
"always" => FooterMode::Always,
|
||||
_ => match &val_str.parse::<u64>() {
|
||||
Ok(number) => FooterMode::RowCount(*number),
|
||||
_ => FooterMode::Never,
|
||||
},
|
||||
};
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user