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
411 downloads per month
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