Skip to main content

clap_reverse_impl/
lib.rs

1//! Internal implementation crate for `clap_reverse_derive`.
2//!
3//! This crate contains the parsing, validation, and code generation logic for the `ClapReverse` derive macro.
4//!
5//! ## Components
6//!
7//! - [`AsCommand`] – trait defining how a struct is turned into a [`std::process::Command`].
8//! - [`StructAttributes`] – parses and holds struct-level attributes (`display`, `binary`, `prefix`, `delimiter`).
9//! - [`FieldAttributes`] – parses and holds field-level attributes (`prefix`, `name`, `delimiter`, `binary`, `transparent`, `flag`).
10//! - [`ClapReverseGenerator`] – core generator that validates attributes and expands the derive macro into trait impls.
11//!
12//! ## Notes
13//! - All procedural macro entry points live in `clap_reverse_derive`; this crate only provides the machinery.
14//! - Errors during parsing or validation are reported as compile errors via `syn` and `proc_macro2`.
15
16mod as_command;
17pub use as_command::AsCommand;
18
19mod struct_attributes;
20pub use struct_attributes::StructAttributes;
21
22mod field_attributes;
23pub use field_attributes::FieldAttributes;
24
25mod generator;
26pub use generator::ClapReverseGenerator;
27
28mod move_it_somewhere {
29    pub fn find_reverse_clap_attribute(attributes: &[syn::Attribute]) -> Option<&syn::Attribute> {
30        attributes.iter().find(|attr| attr.path().is_ident("clap_reverse"))
31    }
32}