diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 47ada5d1a4..6bc97073ce 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -184,7 +184,6 @@ pub fn create_default_context() -> EngineState { // Strings bind_command! { - BuildString, Char, Decode, Encode, diff --git a/crates/nu-command/src/example_test.rs b/crates/nu-command/src/example_test.rs index 62aeb17a95..20eae2f741 100644 --- a/crates/nu-command/src/example_test.rs +++ b/crates/nu-command/src/example_test.rs @@ -9,8 +9,8 @@ pub fn test_examples(cmd: impl Command + 'static) { #[cfg(test)] mod test_examples { use super::super::{ - Ansi, BuildString, Date, Echo, From, If, Into, LetEnv, Math, Path, Random, Split, - SplitColumn, SplitRow, Str, StrJoin, StrLength, StrReplace, Url, Wrap, + Ansi, Date, Echo, From, If, Into, LetEnv, Math, Path, Random, Split, SplitColumn, SplitRow, + Str, StrJoin, StrLength, StrReplace, Url, Wrap, }; use crate::To; use itertools::Itertools; @@ -64,7 +64,6 @@ mod test_examples { working_set.add_decl(Box::new(StrJoin)); working_set.add_decl(Box::new(StrLength)); working_set.add_decl(Box::new(StrReplace)); - working_set.add_decl(Box::new(BuildString)); working_set.add_decl(Box::new(From)); working_set.add_decl(Box::new(If)); working_set.add_decl(Box::new(To)); diff --git a/crates/nu-command/src/strings/build_string.rs b/crates/nu-command/src/strings/build_string.rs deleted file mode 100644 index 085b9a3510..0000000000 --- a/crates/nu-command/src/strings/build_string.rs +++ /dev/null @@ -1,86 +0,0 @@ -use nu_engine::eval_expression; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; - -#[derive(Clone)] -pub struct BuildString; - -impl Command for BuildString { - fn name(&self) -> &str { - "build-string" - } - - fn usage(&self) -> &str { - "Create a string from the arguments." - } - - fn search_terms(&self) -> Vec<&str> { - vec!["concatenate", "join"] - } - - fn signature(&self) -> nu_protocol::Signature { - Signature::build("build-string") - .rest("rest", SyntaxShape::String, "list of string") - .input_output_types(vec![(Type::Nothing, Type::String)]) - .category(Category::Strings) - } - - fn examples(&self) -> Vec { - vec![ - Example { - example: "build-string a b c", - description: "Builds a string from letters a b c", - result: Some(Value::String { - val: "abc".to_string(), - span: Span::test_data(), - }), - }, - Example { - example: r#"build-string $"(1 + 2)" = one ' ' plus ' ' two"#, - description: "Builds a string from subexpression separating words with spaces", - result: Some(Value::String { - val: "3=one plus two".to_string(), - span: Span::test_data(), - }), - }, - ] - } - - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - let config = engine_state.get_config(); - let output = call - .positional_iter() - .map(|expr| { - eval_expression(engine_state, stack, expr).map(|val| val.into_string(", ", config)) - }) - .collect::, ShellError>>()?; - - Ok(Value::String { - val: output.join(""), - span: call.head, - } - .into_pipeline_data()) - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_examples() { - use crate::test_examples; - - test_examples(BuildString {}) - } -} diff --git a/crates/nu-command/src/strings/mod.rs b/crates/nu-command/src/strings/mod.rs index 3556e54727..317bb43cb0 100644 --- a/crates/nu-command/src/strings/mod.rs +++ b/crates/nu-command/src/strings/mod.rs @@ -1,4 +1,3 @@ -mod build_string; mod char_; mod detect_columns; mod encode_decode; @@ -8,7 +7,6 @@ mod size; mod split; mod str_; -pub use build_string::BuildString; pub use char_::Char; pub use detect_columns::*; pub use encode_decode::*; diff --git a/src/tests/test_strings.rs b/src/tests/test_strings.rs index 8c1b2745fc..f93420e721 100644 --- a/src/tests/test_strings.rs +++ b/src/tests/test_strings.rs @@ -1,39 +1,5 @@ use crate::tests::{fail_test, run_test, TestResult}; -#[test] -fn build_string1() -> TestResult { - run_test("build-string 'nu' 'shell'", "nushell") -} - -#[test] -fn build_string2() -> TestResult { - run_test("'nu' | each { |it| build-string $it 'shell'}", "nushell") -} - -#[test] -fn build_string3() -> TestResult { - run_test( - "build-string 'nu' 'shell' | each { |it| build-string $it ' rocks'}", - "nushell rocks", - ) -} - -#[test] -fn build_string4() -> TestResult { - run_test( - "['sam','rick','pete'] | each { |it| build-string $it ' is studying'} | get 2", - "pete is studying", - ) -} - -#[test] -fn build_string5() -> TestResult { - run_test( - "['sam','rick','pete'] | each { |x| build-string $x ' is studying'} | get 1", - "rick is studying", - ) -} - #[test] fn cjk_in_substrings() -> TestResult { run_test(