use Arc throught the parser

This commit is contained in:
dawn 2026-01-19 17:57:50 +03:00
parent f9367ea041
commit c18e72450b
No known key found for this signature in database
3 changed files with 24 additions and 20 deletions

View file

@ -1,16 +1,16 @@
use std::{collections::HashMap, fmt::Write};
use std::{collections::HashMap, fmt::Write, sync::Arc};
use command_parser::{parameter::ParameterValue, token::TokenMatchResult, Tree};
uniffi::include_scaffolding!("commands");
lazy_static::lazy_static! {
pub static ref COMMAND_TREE: Tree = {
pub static ref COMMAND_TREE: Arc<Tree> = {
let mut tree = Tree::default();
command_definitions::all().into_iter().for_each(|x| tree.register_command(x));
tree
Arc::new(tree)
};
}
@ -125,7 +125,7 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|error| CommandResult::Err { error },
|parsed| CommandResult::Ok {
command: {
let command_ref = parsed.command_def.cb.into();
let command_ref = parsed.command_def.cb.clone().into();
let mut flags = HashMap::with_capacity(parsed.flags.capacity());
for (name, value) in parsed.flags {
flags.insert(name, value.map(Parameter::from));