proc: working command, expose

This commit is contained in:
🪞👃🪞 2025-05-08 13:46:29 +03:00
parent 751e01a41e
commit 046be9a9e1
2 changed files with 24 additions and 13 deletions

View file

@ -62,6 +62,7 @@ impl ToTokens for CommandDef {
let implementations = exposed.values().map(CommandArm::to_implementation);
write_quote_to(out, quote! {
/// Generated by [tengri_proc].
#[derive(Clone, Debug)]
pub enum #enumeration {
#(#variants)*
}
@ -123,9 +124,11 @@ impl CommandArm {
if with_values {
let take_err = LitStr::new(&format!("{}: missing argument \"{}\" ({})",
quote!{#ident}, quote!{#pat}, quote!{#ty}), Span::call_site());
let give_err = LitStr::new(&format!("{}: missing value \"{}\" ({})",
quote!{#ident}, quote!{#pat}, quote!{#ty}), Span::call_site());
write_quote_to(&mut out, quote! {
: Context::get(state, &iter.next().expect(#take_err).value)
});
.expect(#give_err) });
}
} else {
unreachable!("only typed args should be present at this position")