From 491efab09b242942c6db2d6afc5ae0e35df4efab Mon Sep 17 00:00:00 2001 From: xiuxiu62 Date: Sun, 10 Oct 2021 13:24:54 -0700 Subject: [PATCH] remove open and save --- crates/nu-command/src/default_context.rs | 47 ++++++++++++++++++--- crates/nu-command/src/filesystem/mod.rs | 4 -- crates/nu-command/src/filesystem/open.rs | 53 ------------------------ crates/nu-command/src/filesystem/save.rs | 39 ----------------- 4 files changed, 41 insertions(+), 102 deletions(-) delete mode 100644 crates/nu-command/src/filesystem/open.rs delete mode 100644 crates/nu-command/src/filesystem/save.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 52c18e61e6..9e03619cdf 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -23,12 +23,47 @@ pub fn create_default_context() -> Rc> { } // TODO: sort items categorically - #[rustfmt::skip] bind_command!( Alias, Benchmark, BuildString, - Cd, Cp, Def, Do, Each, ExportDef, External, For, From, - FromJson, Get, Griddle, Help, Hide, If, Length, Let, LetEnv, - Lines, Ls, Mkdir, Module, Mv, Open, Ps, Rm, Save, Select, - Split, SplitChars, SplitColumn, SplitRow, Sys, Table, Touch, - Use, Where, Wrap ); + bind_command!( + Alias, + Benchmark, + BuildString, + Cd, + Cp, + Def, + Do, + Each, + ExportDef, + External, + For, + From, + FromJson, + Get, + Griddle, + Help, + Hide, + If, + Length, + Let, + LetEnv, + Lines, + Ls, + Mkdir, + Module, + Mv, + Ps, + Rm, + Select, + Split, + SplitChars, + SplitColumn, + SplitRow, + Sys, + Table, + Touch, + Use, + Where, + Wrap + ); // This is a WIP proof of concept bind_command!(ListGitBranches, Git, GitCheckout, Source); diff --git a/crates/nu-command/src/filesystem/mod.rs b/crates/nu-command/src/filesystem/mod.rs index 241e2c81a9..db5bc4bea6 100644 --- a/crates/nu-command/src/filesystem/mod.rs +++ b/crates/nu-command/src/filesystem/mod.rs @@ -3,9 +3,7 @@ mod cp; mod ls; mod mkdir; mod mv; -mod open; mod rm; -mod save; mod touch; mod util; @@ -14,7 +12,5 @@ pub use cp::Cp; pub use ls::Ls; pub use mkdir::Mkdir; pub use mv::Mv; -pub use open::Open; pub use rm::Rm; -pub use save::Save; pub use touch::Touch; diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs deleted file mode 100644 index 8d1632cc5a..0000000000 --- a/crates/nu-command/src/filesystem/open.rs +++ /dev/null @@ -1,53 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EvaluationContext}; -use nu_protocol::{ShellError, Signature, SyntaxShape, Value}; - -pub struct Open; - -impl Command for Open { - fn name(&self) -> &str { - "open" - } - - fn usage(&self) -> &str { - "Load a file into a cell, convert to table if possible (avoid by appending '--raw')." - } - - fn signature(&self) -> Signature { - Signature::build(self.name()) - .required( - "path", - SyntaxShape::Filepath, - "the file path to load values from", - ) - .switch( - "raw", - "load content as a string instead of a table", - Some('r'), - ) - .named( - "encoding", - SyntaxShape::String, - "encoding to use to open file", - Some('e'), - ) - } - - fn extra_usage(&self) -> &str { - r#"Multiple encodings are supported for reading text files by using -the '--encoding ' parameter. Here is an example of a few: -big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5 - -For a more complete list of encodings please refer to the encoding_rs -documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"# - } - - fn run( - &self, - _context: &EvaluationContext, - _call: &Call, - _input: Value, - ) -> Result { - unimplemented!(); - } -} diff --git a/crates/nu-command/src/filesystem/save.rs b/crates/nu-command/src/filesystem/save.rs deleted file mode 100644 index 4ccff3b312..0000000000 --- a/crates/nu-command/src/filesystem/save.rs +++ /dev/null @@ -1,39 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EvaluationContext}; -use nu_protocol::{ShellError, Signature, SyntaxShape, Value}; - -pub struct Save; - -impl Command for Save { - fn name(&self) -> &str { - "save" - } - - fn signature(&self) -> Signature { - Signature::build("save") - .optional( - "path", - SyntaxShape::Filepath, - "the path to save contents to", - ) - .switch( - "raw", - "treat values as-is rather than auto-converting based on file extension", - Some('r'), - ) - .switch("append", "append values rather than overriding", Some('a')) - } - - fn usage(&self) -> &str { - "Save the contents of the pipeline to a file." - } - - fn run( - &self, - _context: &EvaluationContext, - _call: &Call, - _input: Value, - ) -> Result { - unimplemented!(); - } -}