Skip to main content

cli_core/eval/
convert.rs

1use crate::render::{WireValue, parse_wire};
2use nomiscript::Value;
3
4/// Parse a wire reply and return the value formatted as a string.
5///
6/// Used to surface query results (e.g. `convert`) on the status line
7/// without exposing `nomiscript::Value` to calling crates.
8pub fn parse_scalar_reply(wire: &str) -> Result<String, String> {
9    let value = parse_wire(wire).map_err(|e| e.to_string())?;
10    let WireValue::Value(v) = value;
11    Ok(match v {
12        Value::String(s) => s,
13        other => nomiscript::format_value_display(&other),
14    })
15}