From ac2f6b79e6b1c76ed80114d62024534339bad018 Mon Sep 17 00:00:00 2001 From: amtoine Date: Wed, 8 Mar 2023 19:59:30 +0100 Subject: [PATCH] add a draft body to `run` as in `to json` Real computations are missing and will be added later. --- crates/nu-command/src/formats/to/nuon.rs | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index f9c0ef6ef3..cbde9311bb 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -47,11 +47,30 @@ impl Command for ToNuon { call: &Call, input: PipelineData, ) -> Result { - Ok(Value::String { - val: to_nuon(call, input)?, - span: call.head, + let raw = call.has_flag("raw"); + let use_tabs = call.has_flag("tabs"); + + let span = call.head; + let nuon_value = to_nuon(call, input)?; + + let nuon_result: Result = Ok(nuon_value); + + match nuon_result { + Ok(serde_nuon_string) => Ok(Value::String { + val: serde_nuon_string, + span, + } + .into_pipeline_data()), + _ => Ok(Value::Error { + error: ShellError::CantConvert { + to_type: "NUON".into(), + from_type: "TYPE".to_string(), + span, + help: None, + }, + } + .into_pipeline_data()), } - .into_pipeline_data()) } fn examples(&self) -> Vec {