use entrypoint::prelude::*;
#[derive(entrypoint::clap::Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(short, long, num_args = 1..)]
pub(crate) dotenv_files: Option<Vec<std::path::PathBuf>>,
#[arg(short, long, env, default_value_t = false)]
pub(crate) allow_dotenv_overrides: bool,
}
impl DotEnvParserConfig for Args {
fn additional_dotenv_files(&self) -> Option<Vec<std::path::PathBuf>> {
self.dotenv_files.clone()
}
fn dotenv_can_override(&self) -> bool {
self.allow_dotenv_overrides
}
}
impl LoggerConfig for Args {
fn default_log_level(&self) -> entrypoint::tracing_subscriber::filter::LevelFilter {
<entrypoint::tracing::Level as std::str::FromStr>::from_str(
std::env::var("LOG_LEVEL")
.unwrap_or(String::from("info"))
.as_str(),
)
.expect("failed to parse Level")
.into()
}
}
#[entrypoint::entrypoint]
fn entrypoint(_args: Args) -> entrypoint::anyhow::Result<()> {
info!("dumping env vars...");
for (key, val) in std::env::vars() {
info!("{key}: {val}");
}
trace!("this is a trace");
debug!("this is a debug");
info!("this is an info");
warn!("this is a warn");
error!("this is an error");
Ok(())
}