mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-16 11:46:58 +02:00
feat!: improve CLI structure, add new commands
This splits most CLI/IPC commands into two categories: - `var` for ironvars - `bar` for controlling individual bars. It also introduces more commands for visibility, as well as breaking existing ones. New commands: - `show` - `hide` - `toggle_visible` - `set_popup_visible` - `get_popup_visible` Lastly, the implementation of some existing commands has been improved. BREAKING CHANGE: All IPC commands have changed. Namely, `type` has been changed to `command`, and bar/var related commands are now under a `subcommand`. The full spec can be found on the wiki. BREAKING CHANGE: Several CLI commands are now located under the `var` and `bar` categories. Usage of any commands to get/set Ironvars or control bar visibility will need to be updated. BREAKING CHANGE: The `open_popup` and `close_popup` IPC commands are now called `show_popup` and `hide_popup` respectively. BREAKING CHANGE: The popup `name` argument has been renamed to `widget_name` on all IPC commands. BREAKING CHANGE: The `set-visibility` CLI command now takes a `true`/`false` positional argument in place of the `-v` flag. BREAKING CHANGE: `ok_value` responses will no longer print `ok` as the first line when using the CLI
This commit is contained in:
parent
8dda49477b
commit
9dd711235f
8 changed files with 544 additions and 419 deletions
38
src/ipc/server/ironvar.rs
Normal file
38
src/ipc/server/ironvar.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use crate::ipc::commands::IronvarCommand;
|
||||
use crate::ipc::Response;
|
||||
use crate::{read_lock, write_lock, Ironbar};
|
||||
|
||||
pub fn handle_command(command: IronvarCommand) -> Response {
|
||||
match command {
|
||||
IronvarCommand::Set { key, value } => {
|
||||
let variable_manager = Ironbar::variable_manager();
|
||||
let mut variable_manager = write_lock!(variable_manager);
|
||||
match variable_manager.set(key, value) {
|
||||
Ok(()) => Response::Ok,
|
||||
Err(err) => Response::error(&format!("{err}")),
|
||||
}
|
||||
}
|
||||
IronvarCommand::Get { key } => {
|
||||
let variable_manager = Ironbar::variable_manager();
|
||||
let value = read_lock!(variable_manager).get(&key);
|
||||
match value {
|
||||
Some(value) => Response::OkValue { value },
|
||||
None => Response::error("Variable not found"),
|
||||
}
|
||||
}
|
||||
IronvarCommand::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 }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue