From 8465c743dc5e66532c63af8427a535e0b84b3ee2 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sat, 11 Mar 2023 12:21:08 +0100 Subject: [PATCH] add a few examples --- crates/nu-command/src/formats/to/nuon.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index f74ab1740c..726bea42ed 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -86,11 +86,23 @@ impl Command for ToNuon { } fn examples(&self) -> Vec { - vec![Example { - description: "Outputs a nuon string representing the contents of this list", - example: "[1 2 3] | to nuon", - result: Some(Value::test_string("[1, 2, 3]")), - }] + vec![ + Example { + description: "Outputs a NUON string representing the contents of this list, with default indentation (same as `to nuon --indent 2`)", + example: "[1 2 3] | to nuon", + result: Some(Value::test_string("[\n 1,\n 2,\n 3\n]")), + }, + Example { + description: "Outputs a NUON array of integers, as a raw unformatted NUON string", + example: "[1 2 3] | to nuon --raw", + result: Some(Value::test_string("[1, 2, 3]")) + }, + Example { + description: "A more complex record with multiple data types", + example: "{date: 2000-01-01, data: [1 [2 3] 4.56]} | to nuon", + result: Some(Value::test_string("{\n date: 2000-01-01T00:00:00+00:00,\n data: [\n 1,\n [\n 2,\n 3\n ],\n 4.56\n ]\n}")) + } + ] } }