--- a/cmds/jrsonnet/src/main.rs +++ b/cmds/jrsonnet/src/main.rs @@ -1,6 +1,6 @@ use clap::Clap; use jrsonnet_cli::{ConfigureState, GeneralOpts, InputOpts, ManifestOpts, OutputOpts}; -use jrsonnet_evaluator::{error::LocError, EvaluationState}; +use jrsonnet_evaluator::{error::LocError, EvaluationState, ManifestFormat}; use std::{ fs::{create_dir_all, File}, io::Write, @@ -79,6 +79,7 @@ opts.manifest.configure(&state)?; let val = if opts.input.exec { + state.set_manifest_format(ManifestFormat::ToString); state.evaluate_snippet_raw( Rc::new(PathBuf::from("args")), (&opts.input.input as &str).into(), --- a/crates/jrsonnet-evaluator/src/val.rs +++ b/crates/jrsonnet-evaluator/src/val.rs @@ -201,6 +201,7 @@ YamlStream(Box), Yaml(usize), Json(usize), + ToString, String, } @@ -357,6 +358,7 @@ } ManifestFormat::Yaml(padding) => self.to_yaml(*padding)?, ManifestFormat::Json(padding) => self.to_json(*padding)?, + ManifestFormat::ToString => self.to_string()?, ManifestFormat::String => match self { Self::Str(s) => s.clone(), _ => throw!(StringManifestOutputIsNotAString),