hex_patch/app/plugins/
exported_commands.rs1use crate::app::commands::command_info::CommandInfo;
2
3#[derive(Debug, Default, Clone)]
4pub struct ExportedCommands {
5 pub commands: Vec<CommandInfo>,
6}
7
8impl ExportedCommands {
9 pub fn add_command(&mut self, command: String, description: String) {
11 if let Some(index) = self.commands.iter().position(|c| c.command == command) {
13 self.commands[index].description = description;
14 } else {
15 self.commands.push(CommandInfo::new(command, description));
16 }
17 }
18
19 pub fn remove_command(&mut self, command: &str) -> bool {
20 if let Some(index) = self.commands.iter().position(|c| c.command == command) {
21 self.commands.remove(index);
22 true
23 } else {
24 false
25 }
26 }
27
28 pub fn take(&mut self) -> Self {
29 std::mem::take(self)
30 }
31
32 pub fn get_commands(&self) -> &[CommandInfo] {
33 &self.commands
34 }
35}