feat(daemon, cli): global DaemonConfig and an ability to get/save it using cli (#174)

* use one global Arc<DaemonConfig>

* implement commands

* replace Arc<DaemonConfig> with Arc<Mutex<DaemonConfig>> and fix pwsp-gui

* add pwsp-cli support

* replace serde_json::to_string_pretty with to_string

* refactor

* implement UpdateDaemonConfigCommand and use it in pwsp-gui so it now uses real in-memory config, not the saved one

* implement utils::gui get_daemon_config and update_daemon_config to simplify code
This commit is contained in:
Tarasov Aleksandr
2026-07-24 04:49:51 +03:00
committed by GitHub
parent 5c73bc1bea
commit a33d023950
9 changed files with 141 additions and 30 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
use crate::types::{commands::*, socket::Request};
use crate::types::{commands::*, config::DaemonConfig, socket::Request};
use std::path::PathBuf;
@@ -119,6 +119,17 @@ pub fn parse_command(request: &Request) -> Option<Box<dyn Executable + Send>> {
key_chord,
}))
}
"get_daemon_config" => Some(Box::new(GetDaemonConfigCommand {})),
"save_daemon_config" => Some(Box::new(SaveDaemonConfigCommand {})),
"update_daemon_config" => {
let new_config = request
.args
.get("new_config")
.and_then(|nc| serde_json::from_str::<DaemonConfig>(nc).ok())
.unwrap_or_default();
Some(Box::new(UpdateDaemonConfigCommand { new_config }))
}
_ => None,
}
}