From 37dc22699644250c3504d79c5bc49c89256be3ee Mon Sep 17 00:00:00 2001 From: Leon Date: Thu, 22 Dec 2022 06:51:30 +1000 Subject: [PATCH] Remove preview.rs (#7555) Leftover from `explore` development Closes https://github.com/nushell/nushell/issues/7553 --- crates/nu-explore/src/commands/preview.rs | 79 ----------------------- 1 file changed, 79 deletions(-) delete mode 100644 crates/nu-explore/src/commands/preview.rs diff --git a/crates/nu-explore/src/commands/preview.rs b/crates/nu-explore/src/commands/preview.rs deleted file mode 100644 index 7be8215a7..000000000 --- a/crates/nu-explore/src/commands/preview.rs +++ /dev/null @@ -1,79 +0,0 @@ -use nu_protocol::{ - engine::{EngineState, Stack}, - Value, -}; -use std::io::Result; - -use crate::{ - nu_common::{self, collect_input}, - views::Preview, -}; - -use super::{HelpManual, ViewCommand}; - -#[derive(Default, Clone)] -pub struct PreviewCmd; - -impl PreviewCmd { - pub fn new() -> Self { - Self - } -} - -impl PreviewCmd { - pub const NAME: &'static str = "preview"; -} - -impl ViewCommand for PreviewCmd { - type View = Preview; - - fn name(&self) -> &'static str { - Self::NAME - } - - fn usage(&self) -> &'static str { - "" - } - - fn help(&self) -> Option { - Some(HelpManual { - name: "preview", - description: - "View the currently selected cell's data using the `table` Nushell command", - arguments: vec![], - examples: vec![], - }) - } - - fn parse(&mut self, _: &str) -> Result<()> { - Ok(()) - } - - fn spawn( - &mut self, - engine_state: &EngineState, - stack: &mut Stack, - value: Option, - ) -> Result { - let value = match value { - Some(value) => { - let (cols, vals) = collect_input(value.clone()); - - let has_no_head = cols.is_empty() || (cols.len() == 1 && cols[0].is_empty()); - let has_single_value = vals.len() == 1 && vals[0].len() == 1; - if !has_no_head && has_single_value { - let config = engine_state.get_config(); - vals[0][0].into_abbreviated_string(config) - } else { - let ctrlc = engine_state.ctrlc.clone(); - let config = engine_state.get_config(); - - nu_common::try_build_table(engine_state, stack, ctrlc, config, value) - } - } - None => String::new(), - }; - - Ok(Preview::new(&value)) - } -}