summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..0898daf
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,83 @@
+/*!
+ * Thinking about how best to design this...
+ *
+ * I want to do something different from the original modpackman, mostly in the realm of "i want to make it easier and more portable" (hence rust).
+ *
+ * ## Interface
+ * I want this to be a tad easier to use. There should be one binary to run that does both dependency fixing for modpacks and installation. That binary should have the following subcommands
+ * - apply_updates
+ * - check_updates
+ * - install
+ *
+ * All of these commands should assume that the CWD contains a valid pack.toml and that the pack is valid.
+ *
+ * I'm not sure how packaging this is going to work but it should be fun!
+ */
+
+
+
+use std::process::exit;
+
+use clap::{Parser, Subcommand};
+mod errors;
+mod cli;
+mod util;
+
+use cli::{updates::check_updates, install};
+use errors::CliError;
+use util::{PackConfig, read_pack_config};
+use tracing_subscriber::prelude::*;
+
+#[derive(Parser)]
+#[command(author, version, about)]
+struct Cli {
+ #[command(subcommand)]
+ command: Commands,
+}
+
+#[derive(Subcommand, Clone, Copy)]
+enum Commands {
+ ApplyUpdates { },
+ CheckUpdates { },
+ /// Installs CWD's pack definition into the local .minecraft folder
+ Install { }
+}
+
+#[tokio::main]
+async fn main() {
+ color_eyre::install().unwrap();
+ tracing_subscriber::registry()
+ .with(tracing_subscriber::EnvFilter::new(
+ std::env::var("RUST_LOG").unwrap_or_else(|_| "modpackman_ng=debug,hyper=debug".into()),
+ ))
+ .with(tracing_subscriber::fmt::layer())
+ .init();
+ let cli = Cli::parse();
+
+ let cfg: PackConfig = match read_pack_config() {
+ Ok(c) => c,
+ Err(e) => {
+ println!("Error reading config: {:?}", e);
+ exit(-1);
+ }
+ };
+
+ let res: Result<(), CliError> = match &cli.command {
+ Commands::ApplyUpdates { } => {
+ cli::updates::apply_updates(cfg).await
+ },
+ Commands::CheckUpdates { } => {
+ check_updates(cfg).await
+ },
+ Commands::Install { } => {
+ install::install()
+ }
+ };
+
+ match res {
+ Err(e) => {
+ println!("{:?}", e);
+ },
+ Ok(()) => { },
+ }
+} \ No newline at end of file