initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ife1391ed23a1e7f388b1b5eca90b9ea76a6a6964
This commit is contained in:
commit
ef28bdaeb4
63 changed files with 17292 additions and 0 deletions
176
src/main.rs
Normal file
176
src/main.rs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
mod cli;
|
||||
mod error;
|
||||
mod export;
|
||||
mod fetch;
|
||||
mod git;
|
||||
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;
|
||||
|
||||
use crate::rate_limiter::RateLimiter;
|
||||
|
||||
#[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");
|
||||
|
||||
let _rate_limiter = std::sync::Arc::new(RateLimiter::new(None));
|
||||
|
||||
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.clone(),
|
||||
args.modrinth.clone(),
|
||||
args.github.clone(),
|
||||
args.project_type,
|
||||
args.side,
|
||||
args.strategy,
|
||||
args.redistributable,
|
||||
args.subpath.clone(),
|
||||
args.aliases.clone(),
|
||||
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.clone(),
|
||||
set_args.modrinth_token.clone(),
|
||||
set_args.gh_access_token.clone(),
|
||||
)
|
||||
},
|
||||
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.clone(),
|
||||
prj_args.r#type.as_deref(),
|
||||
prj_args.side.as_deref(),
|
||||
prj_args.update_strategy.as_deref(),
|
||||
prj_args.redistributable,
|
||||
prj_args.subpath.clone(),
|
||||
prj_args.add_alias.clone(),
|
||||
prj_args.remove_alias.clone(),
|
||||
prj_args.export,
|
||||
)
|
||||
},
|
||||
None => {
|
||||
cli::commands::cfg::execute(
|
||||
&config_path,
|
||||
args.name.clone(),
|
||||
args.version.clone(),
|
||||
args.description.clone(),
|
||||
args.author.clone(),
|
||||
args.mods_path.clone(),
|
||||
args.resource_packs_path.clone(),
|
||||
args.data_packs_path.clone(),
|
||||
args.worlds_path.clone(),
|
||||
args.shaders_path.clone(),
|
||||
)
|
||||
},
|
||||
}
|
||||
},
|
||||
Commands::Fork(args) => {
|
||||
cli::commands::fork::execute(&args)?;
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue