mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-24 09:38:32 +02:00
feat(cli): detailed start failure error feedback
This commit ensures that after 3 failures to start komorebi with 'komorebic start', 'komorebi.exe' will be run directly in order to show the detailed error output to the end user.
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -874,6 +874,7 @@ dependencies = [
|
|||||||
"dunce",
|
"dunce",
|
||||||
"fs-tail",
|
"fs-tail",
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
|
"komorebi-client",
|
||||||
"komorebi-core",
|
"komorebi-core",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"miette",
|
"miette",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub use komorebi::NotificationEvent;
|
|||||||
pub use komorebi::RuleDebug;
|
pub use komorebi::RuleDebug;
|
||||||
pub use komorebi::StackbarConfig;
|
pub use komorebi::StackbarConfig;
|
||||||
pub use komorebi::State;
|
pub use komorebi::State;
|
||||||
|
pub use komorebi::StaticConfig;
|
||||||
pub use komorebi::TabsConfig;
|
pub use komorebi::TabsConfig;
|
||||||
pub use komorebi_core::ActiveWindowBorderStyle;
|
pub use komorebi_core::ActiveWindowBorderStyle;
|
||||||
pub use komorebi_core::Arrangement;
|
pub use komorebi_core::Arrangement;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
derive-ahk = { path = "../derive-ahk" }
|
derive-ahk = { path = "../derive-ahk" }
|
||||||
komorebi-core = { path = "../komorebi-core" }
|
komorebi-core = { path = "../komorebi-core" }
|
||||||
|
komorebi-client = { path = "../komorebi-client" }
|
||||||
|
|
||||||
clap = { version = "4", features = ["derive", "wrap_help"] }
|
clap = { version = "4", features = ["derive", "wrap_help"] }
|
||||||
color-eyre = { workspace = true }
|
color-eyre = { workspace = true }
|
||||||
|
|||||||
@@ -1391,6 +1391,11 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that this file adheres to the schema static config schema as the last step,
|
||||||
|
// so that more basic errors above can be shown to the error before schema-specific
|
||||||
|
// errors
|
||||||
|
let _ = serde_json::from_str::<komorebi_client::StaticConfig>(&config_source)?;
|
||||||
|
|
||||||
if config_whkd.exists() {
|
if config_whkd.exists() {
|
||||||
println!("Found {}; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag\n", config_whkd.to_string_lossy());
|
println!("Found {}; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag\n", config_whkd.to_string_lossy());
|
||||||
} else {
|
} else {
|
||||||
@@ -1775,7 +1780,7 @@ fn main() -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut flags = vec![];
|
let mut flags = vec![];
|
||||||
if let Some(config) = arg.config {
|
if let Some(config) = &arg.config {
|
||||||
let path = resolve_home_path(config)?;
|
let path = resolve_home_path(config)?;
|
||||||
if !path.is_file() {
|
if !path.is_file() {
|
||||||
bail!("could not find file: {}", path.display());
|
bail!("could not find file: {}", path.display());
|
||||||
@@ -1810,9 +1815,10 @@ fn main() -> Result<()> {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut attempts = 0;
|
||||||
let mut running = false;
|
let mut running = false;
|
||||||
|
|
||||||
while !running {
|
while !running && attempts <= 2 {
|
||||||
match powershell_script::run(&script) {
|
match powershell_script::run(&script) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("{script}");
|
println!("{script}");
|
||||||
@@ -1833,9 +1839,27 @@ fn main() -> Result<()> {
|
|||||||
running = true;
|
running = true;
|
||||||
} else {
|
} else {
|
||||||
println!("komorebi.exe did not start... Trying again");
|
println!("komorebi.exe did not start... Trying again");
|
||||||
|
attempts += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !running {
|
||||||
|
println!("\nRunning komorebi.exe directly for detailed error output\n");
|
||||||
|
if let Some(config) = arg.config {
|
||||||
|
let path = resolve_home_path(config)?;
|
||||||
|
if let Ok(output) = Command::new("komorebi.exe")
|
||||||
|
.arg(format!("'--config=\"{}\"'", path.display()))
|
||||||
|
.output()
|
||||||
|
{
|
||||||
|
println!("{}", String::from_utf8(output.stderr)?);
|
||||||
|
}
|
||||||
|
} else if let Ok(output) = Command::new("komorebi.exe").output() {
|
||||||
|
println!("{}", String::from_utf8(output.stderr)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if arg.whkd {
|
if arg.whkd {
|
||||||
let script = r"
|
let script = r"
|
||||||
if (!(Get-Process whkd -ErrorAction SilentlyContinue))
|
if (!(Get-Process whkd -ErrorAction SilentlyContinue))
|
||||||
|
|||||||
Reference in New Issue
Block a user