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
47pub struct ExternalModule {
49 pub alias: Ident,
51
52 pub item_use: syn::ItemUse,
54}
55
56impl std::fmt::Debug for TusksParameters {
57 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58 f.debug_struct("TusksParameters")
59 .field("name", &self.pstruct.ident.to_string())
60 .finish()
61 }
62}
63
64impl std::fmt::Debug for Tusk {
65 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
66 f.debug_struct("Tusk")
67 .field("name", &self.func.sig.ident.to_string())
68 .finish()
69 }
70}
71
72impl std::fmt::Debug for ExternalModule {
73 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74 f.debug_struct("ExternalModule")
75 .field("alias", &self.alias.to_string())
76 .field("item_use", &format!("ItemUse at span: {:?}", self.item_use.span()))
77 .finish()
78 }
79}
80
81impl std::fmt::Debug for Attributes {
82 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83 f.debug_struct("Attributes")
84 .field("count", &self.0.len())
85 .field(
86 "attributes",
87 &self.0.iter().map(|attr| {
88 let path_str = attr
89 .path()
90 .segments
91 .iter()
92 .map(|seg: &PathSegment| seg.ident.to_string())
93 .collect::<Vec<_>>()
94 .join("::");
95
96 format!("{} at span: {:?}", path_str, attr.span())
97 }).collect::<Vec<String>>(),
98 )
99 .finish()
100 }
101}