envelope_nested/
envelope_nested.rs1use scriba::{
20 Format, Output,
21 Ui,
22 envelope::{EnvelopeConfig, EnvelopeLayout, EnvelopeMode, Meta},
23};
24
25fn main() -> scriba::Result<()> {
26 let output = Output::new()
27 .title("Pipeline")
28 .data("stage", "build")
29 .data("commit", "a3f9c12")
30 .paragraph("Build succeeded in 42s.");
31
32 let ui = Ui::new()
33 .with_format(Format::Json)
34 .with_envelope(
35 EnvelopeConfig::default()
36 .with_mode(EnvelopeMode::Json)
37 .with_layout(EnvelopeLayout::Nested),
38 );
39
40 println!("=== Nested envelope, no meta ===");
41 ui.print(&output)?;
42
43 println!("\n=== Nested envelope, with meta merged in ===");
44 let meta = Meta::default()
45 .with_dry_run(true)
46 .with_command("ci run".into())
47 .with_timestamp("2026-04-13T09:30:00Z".into())
48 .with_scope("ci".into())
49 .with_version("0.3.0".into());
50 ui.print_with_meta(&output, Some(&meta), true)?;
51
52 Ok(())
53}