Skip to content

Commit

Permalink
Added self-update subcommand (still have flag though)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew121410 committed Sep 20, 2023
1 parent 34766f8 commit 8358de4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use clap::{ArgAction, ArgMatches};
use clap::builder::TypedValueParser;
use colored::Colorize;

use crate::controllers::spigotmc::SpigotAPI;
use crate::backup::BackupFormat;
use crate::controllers::spigotmc::SpigotAPI;
use crate::log_search::LogSearch;
use crate::objects::DownloadedJar::DownloadedJar;

Expand Down Expand Up @@ -52,6 +52,8 @@ async fn main() {
.global(true)
.action(ArgAction::SetTrue)
.required(false))
.subcommand(clap::Command::new("self-update")
.about("Updates Limonium"))
.subcommand(clap::Command::new("download")
.about("Downloads a server jar")
.arg(clap::Arg::new("software")
Expand Down Expand Up @@ -167,15 +169,19 @@ async fn main() {

let command_matches: ArgMatches = matches_commands.get_matches();

// Handle self-update
// Handle self-update flag
if command_matches.get_flag("self-update") {
if self_update() {
process::exit(0); // Exit if updated
return;
}
}

match command_matches.subcommand() {
// Handle self-update subcommand
Some(("self-update", _)) => {
self_update();
process::exit(0);
}
Some(("download", download_matches)) => {
unsafe { SUB_COMMAND_ARG_MATCHES = Some(download_matches.clone()); }
handle_download(&download_matches).await;
Expand Down

0 comments on commit 8358de4

Please sign in to comment.