Skip to content

Commit 41e718f

Browse files
authored
feat(into string): add cell-path input to into string (nushell#16809)
<!-- Thank you for improving Nushell! Please, read our contributing guide: https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md --> ## Release notes summary - What our users need to know Now `into string` accepts a `cell-path` as input. ## Tasks after submitting
1 parent 4d4813b commit 41e718f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

crates/nu-command/src/conversions/into/string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl Command for IntoString {
3838
(Type::Filesize, Type::String),
3939
(Type::Date, Type::String),
4040
(Type::Duration, Type::String),
41+
(Type::CellPath, Type::String),
4142
(Type::Range, Type::String),
4243
(
4344
Type::List(Box::new(Type::Any)),
@@ -141,6 +142,11 @@ impl Command for IntoString {
141142
example: "9day | into string",
142143
result: Some(Value::test_string("1wk 2day")),
143144
},
145+
Example {
146+
description: "convert cell-path to string",
147+
example: "$.name | into string",
148+
result: Some(Value::test_string("$.name")),
149+
},
144150
]
145151
}
146152
}
@@ -217,6 +223,7 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
217223
Value::Date { val, .. } => Value::string(val.format("%c").to_string(), span),
218224
Value::String { val, .. } => Value::string(val, span),
219225
Value::Glob { val, .. } => Value::string(val, span),
226+
Value::CellPath { val, .. } => Value::string(val.to_string(), span),
220227
Value::Filesize { val, .. } => {
221228
if group_digits {
222229
let decimal_value = digits.unwrap_or(0) as usize;

crates/nu-command/tests/commands/str_/into_string.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ fn from_boolean() {
3838
assert_eq!(actual.out, "true");
3939
}
4040

41+
#[test]
42+
fn from_cell_path() {
43+
let actual = nu!(r#"
44+
$.test | into string
45+
"#);
46+
47+
assert_eq!(actual.out, "$.test");
48+
}
49+
4150
#[test]
4251
fn from_string() {
4352
let actual = nu!(r#"

0 commit comments

Comments
 (0)