mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 10:08:33 +02:00
feat(cli): add version update checks
This commit adds version update checks and feedback to the komorebic start and check commands.
This commit is contained in:
@@ -35,6 +35,7 @@ use miette::SourceSpan;
|
|||||||
use paste::paste;
|
use paste::paste;
|
||||||
use schemars::gen::SchemaSettings;
|
use schemars::gen::SchemaSettings;
|
||||||
use schemars::schema_for;
|
use schemars::schema_for;
|
||||||
|
use serde::Deserialize;
|
||||||
use sysinfo::ProcessesToUpdate;
|
use sysinfo::ProcessesToUpdate;
|
||||||
use which::which;
|
use which::which;
|
||||||
use windows::Win32::Foundation::HWND;
|
use windows::Win32::Foundation::HWND;
|
||||||
@@ -1667,6 +1668,30 @@ fn main() -> Result<()> {
|
|||||||
println!("No komorebi configuration found in {home_display}\n");
|
println!("No komorebi configuration found in {home_display}\n");
|
||||||
println!("If running 'komorebic start --await-configuration', you will manually have to call the following command to begin tiling: komorebic complete-configuration\n");
|
println!("If running 'komorebic start --await-configuration', you will manually have to call the following command to begin tiling: komorebic complete-configuration\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
|
||||||
|
if let Ok(response) = client
|
||||||
|
.get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest")
|
||||||
|
.header("User-Agent", "komorebic-version-checker")
|
||||||
|
.send()
|
||||||
|
{
|
||||||
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Release {
|
||||||
|
tag_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(release) =
|
||||||
|
serde_json::from_str::<Release>(&response.text().unwrap_or_default())
|
||||||
|
{
|
||||||
|
let trimmed = release.tag_name.trim_start_matches("v");
|
||||||
|
if trimmed > version {
|
||||||
|
println!("An updated version of komorebi is available! https://github.com/LGUG2Z/komorebi/releases/v{trimmed}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SubCommand::Configuration => {
|
SubCommand::Configuration => {
|
||||||
let static_config = HOME_DIR.join("komorebi.json");
|
let static_config = HOME_DIR.join("komorebi.json");
|
||||||
@@ -2246,6 +2271,30 @@ if (!(Get-Process masir -ErrorAction SilentlyContinue))
|
|||||||
let stdout = String::from_utf8(output.stdout)?;
|
let stdout = String::from_utf8(output.stdout)?;
|
||||||
println!("{stdout}");
|
println!("{stdout}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
|
||||||
|
if let Ok(response) = client
|
||||||
|
.get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest")
|
||||||
|
.header("User-Agent", "komorebic-version-checker")
|
||||||
|
.send()
|
||||||
|
{
|
||||||
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Release {
|
||||||
|
tag_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(release) =
|
||||||
|
serde_json::from_str::<Release>(&response.text().unwrap_or_default())
|
||||||
|
{
|
||||||
|
let trimmed = release.tag_name.trim_start_matches("v");
|
||||||
|
if trimmed > version {
|
||||||
|
println!("An updated version of komorebi is available! https://github.com/LGUG2Z/komorebi/releases/v{trimmed}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SubCommand::Stop(arg) => {
|
SubCommand::Stop(arg) => {
|
||||||
if arg.whkd {
|
if arg.whkd {
|
||||||
|
|||||||
Reference in New Issue
Block a user