use anyhow::Result; use clap::Parser; use libpt::log::{debug, info}; use wooly_vault::config::ENV_SECRET; use wooly_vault::{challenge::select_and_start, config::Config, vault::Vault}; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { let conf = Config::parse(); let _logger = libpt::log::Logger::builder() .set_level(conf.verbosity.level()) .display_time(false) .build()?; debug!("logger active"); info!("Configuration: {conf:?}"); let secret = get_secret()?; let v = Vault::new(&secret); select_and_start(conf.challenge, conf, v).await?; Ok(()) } fn get_secret() -> Result { if let Ok(v) = std::env::var(ENV_SECRET) { return Ok(v); } println!("Input the secret and press enter"); let mut buf: String = String::new(); std::io::stdin().read_line(&mut buf)?; Ok(buf.trim().to_string()) } fn select_challenge() -> Result { let mut buf: String = String::new(); std::io::stdin().read_line(&mut buf)?; Ok(buf.trim().parse()?) }