mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 00:30:11 +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 core::panic;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use ordermap::OrderMap;
|
|
||||||
use smol_str::{format_smolstr, SmolStr};
|
use smol_str::{format_smolstr, SmolStr};
|
||||||
use tree::TreeBranch;
|
use tree::TreeBranch;
|
||||||
|
|
||||||
|
|
@ -19,10 +18,7 @@ pub use token::*;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref COMMAND_TREE: TreeBranch = {
|
pub static ref COMMAND_TREE: TreeBranch = {
|
||||||
let mut tree = TreeBranch {
|
let mut tree = TreeBranch::empty();
|
||||||
current_command_key: None,
|
|
||||||
branches: OrderMap::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
crate::commands::all().into_iter().for_each(|x| tree.register_command(x));
|
crate::commands::all().into_iter().for_each(|x| tree.register_command(x));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,13 @@ pub struct TreeBranch {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TreeBranch {
|
impl TreeBranch {
|
||||||
|
pub fn empty() -> Self {
|
||||||
|
Self {
|
||||||
|
current_command_key: None,
|
||||||
|
branches: OrderMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn register_command(&mut self, command: Command) {
|
pub fn register_command(&mut self, command: Command) {
|
||||||
let mut current_branch = self;
|
let mut current_branch = self;
|
||||||
// iterate over tokens in command
|
// iterate over tokens in command
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue