aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: e48fbbb002866932980a610b720831b52c5866ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only

use std::error::Error;

use whirl::{cli::Cli, utils::log::calculate_log_level};
use whirl_config::Config;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
  // Environment
  let matches = Cli::setup();

  // Logging
  dotenv::dotenv().ok();
  let logger = flexi_logger::Logger::with_str(calculate_log_level());
  if std::env::var("LOG_FILE").unwrap_or_else(|_| "true".to_string()) == "false"
    || !Config::get().whirlsplash.log.file
  {
    logger.start()?;
  } else {
    logger
      .print_message()
      .log_to_file()
      .directory("log")
      .start()?;
  }

  // Execution
  Cli::execute(matches).await.unwrap();

  Ok(())
}