fmt, clippy

This commit is contained in:
Reilly Wood 2024-06-05 19:48:37 -07:00
parent 88f99f0b5d
commit 4391305743
7 changed files with 9 additions and 15 deletions

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
run_pager, run_pager,
util::{create_lscolors, create_map, map_into_value}, util::{create_lscolors, create_map},
PagerConfig, PagerConfig,
}; };
use nu_ansi_term::{Color, Style}; use nu_ansi_term::{Color, Style};
@ -8,8 +8,6 @@ use nu_color_config::{get_color_map, StyleComputer};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::Config; use nu_protocol::Config;
use std::collections::HashMap;
/// A `less` like program to render a [`Value`] as a table. /// A `less` like program to render a [`Value`] as a table.
#[derive(Clone)] #[derive(Clone)]
pub struct Explore; pub struct Explore;
@ -69,7 +67,7 @@ impl Command for Explore {
let nu_config = engine_state.get_config(); let nu_config = engine_state.get_config();
let style_computer = StyleComputer::from_config(engine_state, stack); let style_computer = StyleComputer::from_config(engine_state, stack);
let mut explore_config = ExploreConfig::from_nu_config(&nu_config); let mut explore_config = ExploreConfig::from_nu_config(nu_config);
explore_config.table.show_header = show_head; explore_config.table.show_header = show_head;
explore_config.table.show_index = show_index; explore_config.table.show_index = show_index;
explore_config.table.separator_style = lookup_color(&style_computer, "separator"); explore_config.table.separator_style = lookup_color(&style_computer, "separator");

View File

@ -21,7 +21,7 @@ use terminal_size::{Height, Width};
use views::{BinaryView, Orientation, Preview, RecordView}; use views::{BinaryView, Orientation, Preview, RecordView};
mod util { mod util {
pub use super::nu_common::{create_lscolors, create_map, map_into_value}; pub use super::nu_common::{create_lscolors, create_map};
} }
fn run_pager( fn run_pager(

View File

@ -18,7 +18,7 @@ pub use command::run_command_with_value;
pub use lscolor::{create_lscolors, lscolorize}; pub use lscolor::{create_lscolors, lscolorize};
pub use string::{string_width, truncate_str}; pub use string::{string_width, truncate_str};
pub use table::try_build_table; pub use table::try_build_table;
pub use value::{collect_input, collect_pipeline, create_map, map_into_value}; pub use value::{collect_input, collect_pipeline, create_map};
pub fn has_simple_value(data: &[Vec<Value>]) -> Option<&Value> { pub fn has_simple_value(data: &[Vec<Value>]) -> Option<&Value> {
if data.len() == 1 if data.len() == 1

View File

@ -176,10 +176,6 @@ pub fn create_map(value: &Value) -> Option<HashMap<String, Value>> {
) )
} }
pub fn map_into_value(hm: HashMap<String, Value>) -> Value {
Value::record(hm.into_iter().collect(), NuSpan::unknown())
}
fn unknown_error_value() -> Value { fn unknown_error_value() -> Value {
Value::string(String::from(""), NuSpan::unknown()) Value::string(String::from(""), NuSpan::unknown())
} }

View File

@ -375,13 +375,13 @@ fn draw_info(f: &mut Frame, pager: &mut Pager<'_>, info: ViewInfo) {
if let Some(report) = info.status { if let Some(report) = info.status {
let last_2nd_line = area.bottom().saturating_sub(2); let last_2nd_line = area.bottom().saturating_sub(2);
let area = Rect::new(area.left(), last_2nd_line, area.width, 1); let area = Rect::new(area.left(), last_2nd_line, area.width, 1);
render_status_bar(f, area, report, &pager.config.explore_config); render_status_bar(f, area, report, pager.config.explore_config);
} }
{ {
let last_line = area.bottom().saturating_sub(1); let last_line = area.bottom().saturating_sub(1);
let area = Rect::new(area.left(), last_line, area.width, 1); let area = Rect::new(area.left(), last_line, area.width, 1);
render_cmd_bar(f, area, pager, info.report, &pager.config.explore_config); render_cmd_bar(f, area, pager, info.report, pager.config.explore_config);
} }
} }
@ -389,7 +389,7 @@ fn create_view_config<'a>(pager: &'a Pager<'_>) -> ViewConfig<'a> {
let cfg = &pager.config; let cfg = &pager.config;
ViewConfig::new( ViewConfig::new(
cfg.nu_config, cfg.nu_config,
&cfg.explore_config, cfg.explore_config,
cfg.style_computer, cfg.style_computer,
cfg.lscolors, cfg.lscolors,
) )

View File

@ -89,7 +89,7 @@ impl View for BinaryView {
} }
fn setup(&mut self, cfg: ViewConfig<'_>) { fn setup(&mut self, cfg: ViewConfig<'_>) {
self.settings = settings_from_config(&cfg.explore_config); self.settings = settings_from_config(cfg.explore_config);
let count_rows = let count_rows =
BinaryWidget::new(&self.data, self.settings.opts, Default::default()).count_lines(); BinaryWidget::new(&self.data, self.settings.opts, Default::default()).count_lines();

View File

@ -246,7 +246,7 @@ impl View for TryView<'_> {
let mut r = RecordView::new(vec![], vec![]); let mut r = RecordView::new(vec![], vec![]);
r.setup(config); r.setup(config);
self.table_theme = config.explore_config.table.clone(); self.table_theme = config.explore_config.table;
if let Some(view) = &mut self.table { if let Some(view) = &mut self.table {
view.set_orientation(r.get_orientation_current()); view.set_orientation(r.get_orientation_current());