1use std::process::ExitCode;
4
5use clap::Parser;
6use cli::Cli;
7use simplelog::{Config, SimpleLogger};
8
9use crate::{
10 cache::CacheDir,
11 commands::{compare_source_info, test_files},
12 error::Error,
13};
14
15mod cache;
16mod cli;
17mod cmd;
18mod commands;
19mod consts;
20mod error;
21pub mod sync;
22pub mod testing;
23mod ui;
24
25fn run_command() -> Result<(), Error> {
27 let cli = Cli::parse();
28 SimpleLogger::init(cli.verbose.log_level_filter(), Config::default())?;
29
30 match cli.cmd {
31 cli::Command::TestFiles { cmd, cache_dir } => {
32 let cache_dir = if let Some(path) = cache_dir {
33 CacheDir::from(path)
34 } else {
35 CacheDir::from_xdg()?
36 };
37
38 test_files(cmd, cache_dir)
39 }
40 cli::Command::CompareSrcinfo {
41 pkgbuild_path,
42 srcinfo_path,
43 } => compare_source_info(pkgbuild_path, srcinfo_path),
44 }
45}
46
47fn main() -> ExitCode {
48 if let Err(error) = run_command() {
49 eprintln!("{error}");
50 ExitCode::FAILURE
51 } else {
52 ExitCode::SUCCESS
53 }
54}