()
| 161 | |
| 162 | #[tokio::main] |
| 163 | async fn main() -> Result<()> { |
| 164 | { |
| 165 | use tracing_subscriber::{fmt, EnvFilter}; |
| 166 | let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); |
| 167 | fmt().with_env_filter(filter).with_ansi(false).init(); |
| 168 | } |
| 169 | rustls::crypto::ring::default_provider() |
| 170 | .install_default() |
| 171 | .or_panic("Failed to install default crypto provider"); |
| 172 | |
| 173 | let args = Args::parse(); |
| 174 | match args.command { |
| 175 | Command::Renew { |
| 176 | config, |
| 177 | once, |
| 178 | force, |
| 179 | } => { |
| 180 | renew(&config, once, force).await?; |
| 181 | } |
| 182 | Command::Init { config } => { |
| 183 | let config = load_config(&config).context("Failed to load configuration")?; |
| 184 | // The build_bot() will trigger the initialization and create Account if not exists |
| 185 | let _bot = config.build_bot().await.context("Failed to build bot")?; |
| 186 | } |
| 187 | Command::SetCaa { config } => { |
| 188 | let bot_config = load_config(&config).context("Failed to load configuration")?; |
| 189 | let bot = bot_config |
| 190 | .build_bot() |
| 191 | .await |
| 192 | .context("Failed to build bot")?; |
| 193 | bot.set_caa().await?; |
| 194 | } |
| 195 | Command::Cfg { write_to } => { |
| 196 | let toml_str = Config::default().to_commented_toml()?; |
| 197 | match write_to { |
| 198 | Some(path) => fs::write(path, toml_str)?, |
| 199 | None => println!("{}", toml_str), |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | Ok(()) |
| 204 | } |
nothing calls this directly
no test coverage detected