1use syn::{Attribute, Ident, ItemFn, ItemStruct, PathSegment, spanned::Spanned};
2
3#[derive(Default)]
4pub struct Attributes(pub Vec<Attribute>);
5
6#[derive(Debug)]
8pub struct TusksModule {
9 pub name: Ident,
11
12 pub attrs: Attributes,
13
14 pub external_parent: Option<ExternalModule>,
16
17 pub parameters: Option<TusksParameters>,
19
20 pub tusks: Vec<Tusk>,
22
23 pub submodules: Vec<TusksModule>,
25
26 pub external_modules: Vec<ExternalModule>,
28
29 pub allow_external_subcommands: bool,
31}
32
33pub struct TusksParameters {
35 pub pstruct: ItemStruct,
37}
38
39pub struct Tusk {
41 pub func: ItemFn,
43
44 pub is_default: bool,
45
46 pub is_async: bool,
47}
48
49pub struct ExternalModule {
51 pub alias: Ident,
53
54 pub item_use: syn::ItemUse,
56}
57
58impl std::fmt::Debug for TusksParameters {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60 f.debug_struct("TusksParameters")
61 .field("name", &self.pstruct.ident.to_string())
62 .finish()
63 }
64}
65
66impl std::fmt::Debug for Tusk {
67 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
68 f.debug_struct("Tusk")
69 .field("name", &self.func.sig.ident.to_string())
70 .finish()
71 }
72}
73
74impl std::fmt::Debug for ExternalModule {
75 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
76 f.debug_struct("ExternalModule")
77 .field("alias", &self.alias.to_string())
78 .field("item_use", &format!("ItemUse at span: {:?}", self.item_use.span()))
79 .finish()
80 }
81}
82
83impl std::fmt::Debug for Attributes {
84 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85 f.debug_struct("Attributes")
86 .field("count", &self.0.len())
87 .field(
88 "attributes",
89 &self.0.iter().map(|attr| {
90 let path_str = attr
91 .path()
92 .segments
93 .iter()
94 .map(|seg: &PathSegment| seg.ident.to_string())
95 .collect::<Vec<_>>()
96 .join("::");
97
98 format!("{} at span: {:?}", path_str, attr.span())
99 }).collect::<Vec<String>>(),
100 )
101 .finish()
102 }
103}