mirror of
https://github.com/nushell/nushell.git
synced 2025-06-01 15:46:04 +02:00
Evolve StrCollect into StrJoin
This commit is contained in:
parent
28cb644a8a
commit
87b82f68fe
@ -200,6 +200,7 @@ pub fn create_default_context() -> EngineState {
|
||||
StrDistance,
|
||||
StrDowncase,
|
||||
StrEndswith,
|
||||
StrJoin,
|
||||
StrReplace,
|
||||
StrIndexOf,
|
||||
StrKebabCase,
|
||||
|
@ -14,7 +14,7 @@ use crate::To;
|
||||
#[cfg(test)]
|
||||
use super::{
|
||||
Ansi, Date, From, If, Into, LetEnv, Math, Path, Random, Split, SplitColumn, SplitRow, Str,
|
||||
StrCollect, StrLength, StrReplace, Url, Wrap,
|
||||
StrJoin, StrLength, StrReplace, Url, Wrap,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@ -29,7 +29,7 @@ pub fn test_examples(cmd: impl Command + 'static) {
|
||||
// Try to keep this working set small to keep tests running as fast as possible
|
||||
let mut working_set = StateWorkingSet::new(&*engine_state);
|
||||
working_set.add_decl(Box::new(Str));
|
||||
working_set.add_decl(Box::new(StrCollect));
|
||||
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));
|
||||
|
@ -7,15 +7,15 @@ use nu_protocol::{
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct StrCollect;
|
||||
pub struct StrJoin;
|
||||
|
||||
impl Command for StrCollect {
|
||||
impl Command for StrJoin {
|
||||
fn name(&self) -> &str {
|
||||
"str collect"
|
||||
"str join"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str collect")
|
||||
Signature::build("str join")
|
||||
.optional(
|
||||
"separator",
|
||||
SyntaxShape::String,
|
||||
@ -29,7 +29,7 @@ impl Command for StrCollect {
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["join", "concatenate"]
|
||||
vec!["collect", "concatenate"]
|
||||
}
|
||||
|
||||
fn run(
|
||||
@ -76,7 +76,7 @@ impl Command for StrCollect {
|
||||
vec![
|
||||
Example {
|
||||
description: "Create a string from input",
|
||||
example: "['nu', 'shell'] | str collect",
|
||||
example: "['nu', 'shell'] | str join",
|
||||
result: Some(Value::String {
|
||||
val: "nushell".to_string(),
|
||||
span: Span::test_data(),
|
||||
@ -84,7 +84,7 @@ impl Command for StrCollect {
|
||||
},
|
||||
Example {
|
||||
description: "Create a string from input with a separator",
|
||||
example: "['nu', 'shell'] | str collect '-'",
|
||||
example: "['nu', 'shell'] | str join '-'",
|
||||
result: Some(Value::String {
|
||||
val: "nu-shell".to_string(),
|
||||
span: Span::test_data(),
|
||||
@ -101,6 +101,6 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(StrCollect {})
|
||||
test_examples(StrJoin {})
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ mod contains;
|
||||
mod distance;
|
||||
mod ends_with;
|
||||
mod index_of;
|
||||
mod join;
|
||||
mod length;
|
||||
mod lpad;
|
||||
mod replace;
|
||||
@ -19,6 +20,7 @@ pub use contains::SubCommand as StrContains;
|
||||
pub use distance::SubCommand as StrDistance;
|
||||
pub use ends_with::SubCommand as StrEndswith;
|
||||
pub use index_of::SubCommand as StrIndexOf;
|
||||
pub use join::*;
|
||||
pub use length::SubCommand as StrLength;
|
||||
pub use lpad::SubCommand as StrLpad;
|
||||
pub use replace::SubCommand as StrReplace;
|
||||
|
Loading…
x
Reference in New Issue
Block a user