use bashexpand::expand;
fn main() {
let mut ctx = |name: &str| match name {
"user" => Some(whoami()),
"shell" => std::env::var("SHELL").ok(),
_ => None,
};
let line = expand(
"${user@u} uses ${shell##*/} (config: ${cfg:-~/.config/app.toml})",
&mut ctx,
)
.unwrap();
println!("{line}");
}
fn whoami() -> String {
std::env::var("USER").unwrap_or_else(|_| "somebody".to_string())
}