#cargo #instructions #build #tool

build vergen-pretty

Output vergen information in a formatted manner

5 unstable releases

0.3.0 May 24, 2023
0.2.0 May 18, 2023
0.1.2 Apr 25, 2023
0.1.1 Jan 10, 2023
0.1.0 Jan 8, 2023

#225 in Build Utils

Download history 160/week @ 2023-02-11 121/week @ 2023-02-18 143/week @ 2023-02-25 215/week @ 2023-03-04 115/week @ 2023-03-11 106/week @ 2023-03-18 118/week @ 2023-03-25 87/week @ 2023-04-01 90/week @ 2023-04-08 91/week @ 2023-04-15 109/week @ 2023-04-22 101/week @ 2023-04-29 81/week @ 2023-05-06 111/week @ 2023-05-13 113/week @ 2023-05-20 94/week @ 2023-05-27

411 downloads per month

MIT/Apache

72KB
2K SLoC

vergen-pretty

A pretty printer for vergen generated environment variables


lib.rs:

vergen-pretty - A pretty printer for vergen environment variables

Because cargo doesn't pass compile time environment variables to dependencies, the [vergen_pretty_env] macro embeds a map of all the possible vergen environment variables with option_env!. Values not set in by your build.rs are skipped when pretty-printing the output.

Example

# use anyhow::Result;
# use std::{collections::BTreeMap, io::Write};
# use vergen_pretty::{vergen_pretty_env, PrettyBuilder};
# fn has_value(
#     tuple: (&&'static str, &Option<&'static str>),
# ) -> Option<(&'static str, &'static str)> {
#     let (key, value) = tuple;
#     if value.is_some() {
#         Some((*key, value.unwrap_or_default()))
#     } else {
#         None
#     }
# }
# fn is_empty(map: &BTreeMap<&'static str, Option<&'static str>>) -> bool {
#     map.iter().filter_map(has_value).count() == 0
# }
# fn main() -> Result<()> {
let mut stdout = vec![];
# let map = vergen_pretty_env!();
# let empty = is_empty(&map);
PrettyBuilder::default()
    .env(vergen_pretty_env!())
    .build()?
    .display(&mut stdout)?;
# if empty {
#    assert!(stdout.is_empty());
# } else {
assert!(!stdout.is_empty());
# }
#     Ok(())
# }

See the Pretty documentation for more examples

Features

vergen-pretty has two feature toggles allowing you to customize your output. No features are enabled by default.
You must specifically enable the features you wish to use.

Feature Enables
color Colorize output, allow configuration of coloring via [console]
trace Enable support for tracing output

Dependencies

~2–10MB
~168K SLoC