From 52e8b0afb28615c33707de524fc6479a8c1a61c0 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Sun, 22 Oct 2023 00:21:34 +0800 Subject: [PATCH] Deprecate `size` to `str stats` (#10798) # Description Rename `str size` to `str stats`, for more detail see: https://github.com/nushell/nushell/pull/10772 # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/default_context.rs | 2 +- crates/nu-command/src/strings/size.rs | 2 +- crates/nu-command/src/strings/str_/mod.rs | 4 ++-- .../src/strings/str_/{size.rs => stats.rs} | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) rename crates/nu-command/src/strings/str_/{size.rs => stats.rs} (97%) diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 6b63204aa..1029cff26 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -190,7 +190,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { StrIndexOf, StrLength, StrReverse, - StrSize, + StrStats, StrStartsWith, StrSubstring, StrTrim, diff --git a/crates/nu-command/src/strings/size.rs b/crates/nu-command/src/strings/size.rs index 918d4aca7..9e4a95851 100644 --- a/crates/nu-command/src/strings/size.rs +++ b/crates/nu-command/src/strings/size.rs @@ -46,7 +46,7 @@ impl Command for Size { "Deprecated command".into(), "`size` is deprecated and will be removed in 0.88.".into(), Some(call.head), - Some("Use `str size` instead".into()), + Some("Use `str stats` instead".into()), vec![], ), ); diff --git a/crates/nu-command/src/strings/str_/mod.rs b/crates/nu-command/src/strings/str_/mod.rs index f5c705f71..fb34ace83 100644 --- a/crates/nu-command/src/strings/str_/mod.rs +++ b/crates/nu-command/src/strings/str_/mod.rs @@ -8,8 +8,8 @@ mod join; mod length; mod replace; mod reverse; -mod size; mod starts_with; +mod stats; mod substring; mod trim; @@ -23,7 +23,7 @@ pub use join::*; pub use length::SubCommand as StrLength; pub use replace::SubCommand as StrReplace; pub use reverse::SubCommand as StrReverse; -pub use size::SubCommand as StrSize; pub use starts_with::SubCommand as StrStartsWith; +pub use stats::SubCommand as StrStats; pub use substring::SubCommand as StrSubstring; pub use trim::Trim as StrTrim; diff --git a/crates/nu-command/src/strings/str_/size.rs b/crates/nu-command/src/strings/str_/stats.rs similarity index 97% rename from crates/nu-command/src/strings/str_/size.rs rename to crates/nu-command/src/strings/str_/stats.rs index 4cfce108b..842e99f1b 100644 --- a/crates/nu-command/src/strings/str_/size.rs +++ b/crates/nu-command/src/strings/str_/stats.rs @@ -16,11 +16,11 @@ pub struct SubCommand; impl Command for SubCommand { fn name(&self) -> &str { - "str size" + "str stats" } fn signature(&self) -> Signature { - Signature::build("str size") + Signature::build("str stats") .category(Category::Strings) .input_output_types(vec![(Type::String, Type::Record(vec![]))]) } @@ -40,14 +40,14 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - size(engine_state, call, input) + stats(engine_state, call, input) } fn examples(&self) -> Vec { vec![ Example { description: "Count the number of words in a string", - example: r#""There are seven words in this sentence" | str size"#, + example: r#""There are seven words in this sentence" | str stats"#, result: Some(Value::test_record(Record { cols: vec![ "lines".into(), @@ -67,7 +67,7 @@ impl Command for SubCommand { }, Example { description: "Counts unicode characters", - example: r#"'今天天气真好' | str size "#, + example: r#"'今天天气真好' | str stats "#, result: Some(Value::test_record(Record { cols: vec![ "lines".into(), @@ -87,7 +87,7 @@ impl Command for SubCommand { }, Example { description: "Counts Unicode characters correctly in a string", - example: r#""Amélie Amelie" | str size"#, + example: r#""Amélie Amelie" | str stats"#, result: Some(Value::test_record(Record { cols: vec![ "lines".into(), @@ -109,7 +109,7 @@ impl Command for SubCommand { } } -fn size( +fn stats( engine_state: &EngineState, call: &Call, input: PipelineData,