mod palette;
mod recents;
mod registry;
mod rules;
mod run;
mod search;
mod state;
mod table;
pub(in crate::gui) use palette::setup_command_palette;
pub(in crate::gui) use run::{add_tier, set_solid_view_mode, show_edit_view, show_inspector_tab};
#[cfg(test)]
pub(in crate::gui) use table::COMMANDS;
use crate::MainWindow;
use state::CommandState;
pub(in crate::gui) fn run_unlocked(ui: &MainWindow, id: &str) -> Result<(), String> {
let command = table::COMMANDS
.iter()
.find(|command| command.id == id)
.ok_or_else(|| format!("There is no command {id:?}."))?;
command
.availability(&CommandState::capture(ui).without_guide_locks())
.map_err(|reason| palette::blocked_message(command.title, reason))?;
(command.run)(ui);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use indicatrix_editor::guide::PERFORM_COMMANDS;
#[test]
fn every_command_a_guide_step_may_run_is_in_the_table() {
for id in PERFORM_COMMANDS {
assert!(
table::COMMANDS.iter().any(|command| command.id == *id),
"the guide may run {id}, which the command table does not have"
);
}
}
}