diff --git a/src/command.rs b/src/command.rs index 244b34ac..0c8bea10 100644 --- a/src/command.rs +++ b/src/command.rs @@ -40,7 +40,12 @@ impl Command { } else { "/" }; - String::from(prefix) + &self.name + if let Some(rule) = &global_parameters.rename_rule { + String::from(prefix) + &rename_by_rule(&self.name, rule.as_str()) + } + else { + String::from(prefix) + &self.name + } } } diff --git a/src/enum_attributes.rs b/src/enum_attributes.rs index 728b80eb..1ca59636 100644 --- a/src/enum_attributes.rs +++ b/src/enum_attributes.rs @@ -1,5 +1,6 @@ use crate::attr::{Attr, BotCommandAttribute}; +#[derive(Debug)] pub struct CommandEnum { pub prefix: Option, pub description: Option, diff --git a/src/fields_parse.rs b/src/fields_parse.rs index 6abff534..2eb1998d 100644 --- a/src/fields_parse.rs +++ b/src/fields_parse.rs @@ -1,11 +1,13 @@ extern crate quote; -use quote::quote; +use quote::{quote}; use syn::FieldsUnnamed; pub fn impl_parse_args_unnamed(data: &FieldsUnnamed) -> quote::__rt::TokenStream { let iter = 0..data.unnamed.len(); - quote! { - (#(FromStr::from_str(args.get(#iter)),)*) + let mut tokens = quote! {}; + for _ in iter { + tokens.extend(quote! { CommandArgument::parse(&mut args)?, }); } + quote! { (#tokens) } } diff --git a/src/lib.rs b/src/lib.rs index c525117e..01d6bc8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,8 +103,8 @@ fn impl_descriptions(infos: &[Command], global: &CommandEnum) -> quote::__rt::To }); quote! { - fn descriptions() -> &'static str { - std::concat!(#global_description #(#command, #description, '\n'),*) + fn descriptions() -> String { + std::concat!(#global_description #(#command, #description, '\n'),*).to_string() } } } @@ -123,7 +123,7 @@ fn impl_parse( where N: Into { - let mut words = s.split_whitespace(); + let mut words = s.splitn(2, ' '); let mut splited = words.next()?.split('@'); let command_raw = splited.next()?; let bot = splited.next(); @@ -133,7 +133,7 @@ fn impl_parse( None => {} _ => return None, } - let args: Vec<&str> = words.collect(); + let mut args = words.next().unwrap_or("").to_string(); match command_raw { #( #matching_values => Some(Self::#variant_ident #variants_initialization),