// Allow pre-existing clippy warnings for functions with many arguments // and complex types that would require significant refactoring #![allow(clippy::too_many_arguments)] #![allow(clippy::type_complexity)] #![allow(clippy::large_enum_variant)] mod cli; mod error; mod export; mod fetch; mod git; mod http; mod ipc; mod model; mod platform; mod rate_limiter; mod resolver; mod ui_utils; mod utils; use std::path::PathBuf; use clap::Parser; use cli::{Cli, Commands}; use error::PakkerError; #[tokio::main] async fn main() -> Result<(), PakkerError> { let cli = Cli::parse(); // Initialize logging based on verbosity level let log_level = match cli.verbose { 0 => "warn", // Default: only warnings and errors 1 => "info", // -v: info level 2 => "debug", // -vv: debug level _ => "trace", // -vvv+: trace level (most verbose) }; env_logger::Builder::from_env( env_logger::Env::default().default_filter_or(log_level), ) .format_timestamp(None) .format_module_path(false) .init(); let working_dir = PathBuf::from("."); let lockfile_path = working_dir.join("pakker-lock.json"); let config_path = working_dir.join("pakker.json"); match cli.command { Commands::Init(args) => { cli::commands::init::execute(args, &lockfile_path, &config_path).await }, Commands::Import(args) => { cli::commands::import::execute(args, &lockfile_path, &config_path).await }, Commands::Add(args) => { cli::commands::add::execute(args, &lockfile_path, &config_path).await }, Commands::AddPrj(args) => { cli::commands::add_prj::execute( args.curseforge, args.modrinth, args.github, args.project_type, args.side, args.strategy, args.redistributable, args.subpath, args.aliases, args.export, args.no_deps, args.yes, &lockfile_path, &config_path, ) .await }, Commands::Rm(args) => { cli::commands::rm::execute(args, &lockfile_path, &config_path).await }, Commands::Update(args) => { cli::commands::update::execute(args, &lockfile_path, &config_path).await }, Commands::Ls(args) => cli::commands::ls::execute(args, &lockfile_path), Commands::Set(args) => { cli::commands::set::execute(args, &lockfile_path, &config_path).await }, Commands::Link(args) => cli::commands::link::execute(args, &lockfile_path), Commands::Unlink(args) => { cli::commands::unlink::execute(args, &lockfile_path) }, Commands::Diff(args) => cli::commands::diff::execute(args, &lockfile_path), Commands::Fetch(args) => { cli::commands::fetch::execute(args, &lockfile_path, &config_path).await }, Commands::Sync(args) => { cli::commands::sync::execute(args, &lockfile_path, &config_path).await }, Commands::Export(args) => { cli::commands::export::execute(args, &lockfile_path, &config_path).await }, Commands::Remote(args) => cli::commands::remote::execute(args).await, Commands::RemoteUpdate(args) => { cli::commands::remote_update::execute(args).await }, Commands::Status(args) => { cli::commands::status::execute( args.parallel, &lockfile_path, &config_path, ) .await }, Commands::Inspect(args) => { cli::commands::inspect::execute( args.projects, &lockfile_path, &config_path, ) .await }, Commands::Credentials(args) => { match args.subcommand { Some(cli::CredentialsSubcommand::Set(set_args)) => { cli::commands::credentials_set::execute( set_args.cf_api_key, set_args.modrinth_token, set_args.gh_access_token, ) }, None => { cli::commands::credentials::execute( args.delete, args.delete_file, args.delete_keyring, ) }, } }, Commands::Cfg(args) => { match args.subcommand { Some(cli::CfgSubcommand::Prj(prj_args)) => { cli::commands::cfg_prj::execute( &config_path, &lockfile_path, prj_args.project, prj_args.r#type.as_deref(), prj_args.side.as_deref(), prj_args.update_strategy.as_deref(), prj_args.redistributable, prj_args.subpath, prj_args.add_alias, prj_args.remove_alias, prj_args.export, ) }, None => { cli::commands::cfg::execute( &config_path, args.name, args.version, args.description, args.author, args.mods_path, args.resource_packs_path, args.data_packs_path, args.worlds_path, args.shaders_path, ) }, } }, Commands::Fork(args) => { cli::commands::fork::execute(&args)?; Ok(()) }, } }