From 38222328c2ad9de4dbe245bddb897748bb36d5ad Mon Sep 17 00:00:00 2001 From: Byson94 Date: Mon, 29 Sep 2025 12:38:37 +0530 Subject: [PATCH] feat: fixed falure send & added print flag to engine-override --- CHANGELOG.md | 1 + crates/ewwii/src/app.rs | 30 +++++++++++++++++------------- crates/ewwii/src/opts.rs | 9 +++++++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57792be..00a82f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Logs not truncating if it is over 100MB and not deleting if over 7 days old. - Ewwii crashing on invalid duration property. - The module resolver throwing error at `import` defenition. +- Fixed commands sending error with success status. ### Removed diff --git a/crates/ewwii/src/app.rs b/crates/ewwii/src/app.rs index 50f786b..4a830b0 100644 --- a/crates/ewwii/src/app.rs +++ b/crates/ewwii/src/app.rs @@ -90,6 +90,7 @@ pub enum DaemonCommand { }, EngineOverride { config: String, + print: bool, sender: DaemonResponseSender, }, } @@ -329,25 +330,28 @@ impl App { } } DaemonCommand::TriggerUpdateUI { inject_vars, should_preserve_state, sender } => { - let output = match self.trigger_ui_update_with(inject_vars, should_preserve_state) { - Ok(_) => String::new(), - Err(e) => e.to_string(), + match self.trigger_ui_update_with(inject_vars, should_preserve_state) { + Ok(_) => sender.send_success(String::new())?, + Err(e) => sender.send_failure(e.to_string())?, }; - sender.send_success(output)? } DaemonCommand::CallRhaiFns { calls, sender } => { - let output = match self.call_rhai_fns(calls) { - Ok(_) => String::new(), - Err(e) => e.to_string(), + match self.call_rhai_fns(calls) { + Ok(_) => sender.send_success(String::new())?, + Err(e) => sender.send_failure(e.to_string())?, }; - sender.send_success(output)? } - DaemonCommand::EngineOverride { config, sender } => { - let output = match self.set_engine_overrides(config) { - Ok(_) => String::new(), - Err(e) => e.to_string(), + DaemonCommand::EngineOverride { config, print, sender } => { + match self.set_engine_overrides(config) { + Ok(_) => { + if print { + sender.send_success(format!("{:#?}", self.rt_engine_config))? + } else { + sender.send_success(String::new())? + } + } + Err(e) => sender.send_failure(e.to_string())?, }; - sender.send_success(output)? } } Ok(()) diff --git a/crates/ewwii/src/opts.rs b/crates/ewwii/src/opts.rs index 189a939..ce52d18 100644 --- a/crates/ewwii/src/opts.rs +++ b/crates/ewwii/src/opts.rs @@ -191,7 +191,7 @@ pub enum ActionWithServer { /// /// Format: --inject foo="val1" baz="val2" /// Only variables used by the widget tree will affect the UI. - #[arg(long = "inject", short, value_parser = parse_inject_var_map)] + #[arg(long = "inject", short = 'i', value_parser = parse_inject_var_map)] inject_vars: Option>, /// Preserve the new updates. Only meaningful if used with inject. @@ -212,6 +212,10 @@ pub enum ActionWithServer { EngineOverride { /// Configuration in JSON format config_json: String, + + /// Weather to print the current engine settings + #[arg(long = "sprint", short = 'p')] + print: bool, }, } @@ -344,9 +348,10 @@ impl ActionWithServer { ActionWithServer::ShowDebug => { return with_response_channel(app::DaemonCommand::PrintDebug) } - ActionWithServer::EngineOverride { config_json } => { + ActionWithServer::EngineOverride { config_json, print } => { return with_response_channel(|sender| app::DaemonCommand::EngineOverride { config: config_json, + print, sender, }) }