envelope_meta/
envelope_meta.rs1use scriba::{
12 Format, Output,
13 Ui,
14 envelope::{EnvelopeConfig, EnvelopeLayout, EnvelopeMode, Meta},
15};
16
17fn main() -> scriba::Result<()> {
18 let output = Output::new()
19 .title("Release")
20 .data("tag", "v0.3.0")
21 .paragraph("Release pipeline completed.");
22
23 let meta = Meta::default()
24 .with_dry_run(false)
25 .with_command("release publish".into())
26 .with_duration_ms(4821)
27 .with_timestamp("2026-04-13T18:00:00Z".into())
28 .with_scope("production".into())
29 .with_version("0.3.0".into())
30 .with_extra("region", "eu-west-1")
32 .with_extra("actor", "github-actions")
33 .with_extra("run_id", 9_981_234_u64);
34
35 println!("=== Full meta — flat layout ===");
36 let flat_ui = Ui::new()
37 .with_format(Format::Json)
38 .with_envelope(
39 EnvelopeConfig::default()
40 .with_mode(EnvelopeMode::Json)
41 .with_layout(EnvelopeLayout::Flat),
42 );
43 flat_ui.print_with_meta(&output, Some(&meta), true)?;
44
45 println!("\n=== Full meta — nested layout (all fields merged under meta) ===");
46 let nested_ui = Ui::new()
47 .with_format(Format::Json)
48 .with_envelope(
49 EnvelopeConfig::default()
50 .with_mode(EnvelopeMode::Json)
51 .with_layout(EnvelopeLayout::Nested),
52 );
53 nested_ui.print_with_meta(&output, Some(&meta), true)?;
54
55 println!("\n=== Meta with non-JSON output format (text rendered inside envelope) ===");
56 let text_ui = Ui::new()
57 .with_format(Format::Text)
58 .with_envelope(
59 EnvelopeConfig::default()
60 .with_mode(EnvelopeMode::Json)
61 .with_layout(EnvelopeLayout::Flat),
62 );
63 text_ui.print_with_meta(&output, Some(&meta), true)?;
64
65 Ok(())
66}