1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-03 19:51:03 +02:00

feat(ipc): ironvar list command

This commit is contained in:
Jake Stanger 2024-04-13 23:08:45 +01:00
parent 7e7b3039eb
commit cfaba87f2f
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 38 additions and 3 deletions

View file

@ -32,6 +32,9 @@ pub enum Command {
key: Box<str>,
},
/// Gets the current value of all `ironvar`s.
List,
/// Load an additional CSS stylesheet.
/// The sheet is automatically hot-reloaded.
LoadCss {

View file

@ -153,6 +153,20 @@ impl Ipc {
None => Response::error("Variable not found"),
}
}
Command::List => {
let variable_manager = Ironbar::variable_manager();
let mut values = read_lock!(variable_manager)
.get_all()
.iter()
.map(|(k, v)| format!("{k}: {}", v.get().unwrap_or_default()))
.collect::<Vec<_>>();
values.sort();
let value = values.join("\n");
Response::OkValue { value }
}
Command::LoadCss { path } => {
if path.exists() {
load_css(path);