mirror of
https://github.com/nushell/nushell.git
synced 2025-01-18 12:22:21 +01:00
let to nuon
convert column names with spaces (#6376)
* let `to nuon` convert column names with spaces * change test
This commit is contained in:
parent
37bc90c62a
commit
56ce10347e
@ -102,6 +102,10 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
|
|||||||
let headers = get_columns(vals);
|
let headers = get_columns(vals);
|
||||||
if !headers.is_empty() && vals.iter().all(|x| x.columns() == headers) {
|
if !headers.is_empty() && vals.iter().all(|x| x.columns() == headers) {
|
||||||
// Table output
|
// Table output
|
||||||
|
let headers: Vec<String> = headers
|
||||||
|
.iter()
|
||||||
|
.map(|string| format!("\"{}\"", string))
|
||||||
|
.collect();
|
||||||
let headers_output = headers.join(", ");
|
let headers_output = headers.join(", ");
|
||||||
|
|
||||||
let mut table_output = vec![];
|
let mut table_output = vec![];
|
||||||
|
@ -238,3 +238,14 @@ fn float_nan_parsed_properly() {
|
|||||||
|
|
||||||
assert_eq!(actual.out, "NaN")
|
assert_eq!(actual.out, "NaN")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn to_nuon_converts_columns_with_spaces() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: "tests/fixtures/formats", pipeline(
|
||||||
|
r#"
|
||||||
|
let test = [[a, b, "c d"]; [1 2 3] [4 5 6]]; $test | to nuon | from nuon
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
assert!(actual.err.is_empty());
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user