Skip to content

Commit

Permalink
add --version-local, --version-cdn
Browse files Browse the repository at this point in the history
return respective revision numbers
  • Loading branch information
mxve committed Mar 20, 2022
1 parent a178988 commit 946a404
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions res/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ extern crate winres;
#[cfg(windows)]
fn main() {
let mut res = winres::WindowsResource::new();
res.set_icon("res/icon.ico")
.set_language(0x0409);
res.set_icon("res/icon.ico").set_language(0x0409);

if let Err(e) = res.compile() {
eprintln!("{}", e);
Expand All @@ -14,5 +13,4 @@ fn main() {
}

#[cfg(unix)]
fn main() {
}
fn main() {}
8 changes: 8 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ pub struct Args {
default_value = "https://cdn.plutonium.pw/updater/prod/info.json"
)]
pub cdn_url: String,

/// get local version
#[clap(long)]
pub version_local: bool,

// get cdn version
#[clap(long)]
pub version_cdn: bool,
}

pub fn get() -> Args {
Expand Down
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ fn main() {
let local_info = read_info_file(&Path::join(Path::new(&args.directory), "cdn_info.json"));
let cdn_info = parse_info(&http::get_body_string(&args.cdn_url));

if args.version_local {
println!("{}", local_info.revision);
std::process::exit(0);
}

if args.version_cdn {
println!("{}", cdn_info.revision);
std::process::exit(0);
}

// exit code 1 if outdated, 0 if upto date
if args.check {
if cdn_info.revision > local_info.revision {
std::process::exit(1);
Expand Down Expand Up @@ -326,6 +337,7 @@ fn main() {
std::process::exit(0);
}

// program wasn't closed yet, so its seems like we should run updates
update(&args, &cdn_info, &local_info);
std::process::exit(0);
}

0 comments on commit 946a404

Please sign in to comment.