Skip to content

Commit

Permalink
feat(main.rs): add outdated check
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jul 18, 2022
1 parent d6f05bc commit 81e3937
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "sydney"
version = "0.1.5"
version = "0.1.6"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "Vim-like, Command-line Gemini Client"
Expand Down
27 changes: 27 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,33 @@ Report bugs to https://github.com/gemrest/sydney/issues"#,

let mut stdout = std::io::stdout();

match germ::request::request(
&url::Url::parse("gemini://fuwn.me/api/sydney/version").unwrap(),
) {
Ok(response) =>
if let Some(content) = response.content() {
if content > &String::from(env!("CARGO_PKG_VERSION")) {
app.error = Some(format!(
"Your Sydney version ({}) is outdated. It is recommended that you \
update to the newest version ({}).",
env!("CARGO_PKG_VERSION"),
content,
));
}
} else {
app.error = Some(
"Could not check if Sydney has a newer version because the response \
had no content. Please try again later."
.to_string(),
);
},
Err(error) =>
app.error = Some(format!(
"Could not check if Sydney has a newer version: {}",
error
)),
}

execute!(
stdout,
terminal::EnterAlternateScreen,
Expand Down

0 comments on commit 81e3937

Please sign in to comment.