mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor(commands): move tree branch construct code into type method
This commit is contained in:
parent
c43a855184
commit
3120e62dda
2 changed files with 8 additions and 5 deletions
|
|
@ -10,7 +10,6 @@ uniffi::include_scaffolding!("commands");
|
|||
use core::panic;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use ordermap::OrderMap;
|
||||
use smol_str::{format_smolstr, SmolStr};
|
||||
use tree::TreeBranch;
|
||||
|
||||
|
|
@ -19,10 +18,7 @@ pub use token::*;
|
|||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref COMMAND_TREE: TreeBranch = {
|
||||
let mut tree = TreeBranch {
|
||||
current_command_key: None,
|
||||
branches: OrderMap::new(),
|
||||
};
|
||||
let mut tree = TreeBranch::empty();
|
||||
|
||||
crate::commands::all().into_iter().for_each(|x| tree.register_command(x));
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ pub struct TreeBranch {
|
|||
}
|
||||
|
||||
impl TreeBranch {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
current_command_key: None,
|
||||
branches: OrderMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_command(&mut self, command: Command) {
|
||||
let mut current_branch = self;
|
||||
// iterate over tokens in command
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue