1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// Derive macro to automatically implement [`AsCommand`] for a struct, allowing it
/// to be converted into a [`std::process::Command`]. If `display` is specified
/// in struct attributes, it also implements [`std::fmt::Display`] to show the equivalent
/// command line.
///
/// # Struct-Level Attributes
/// - `display` – generate a `Display` implementation showing the command
/// - `binary` – set the command executable (required if no field has `binary`)
/// - `prefix` – default prefix for arguments (default `"--"`)
/// - `delimiter` – default delimiter between argument name and value (default `" "`)
///
/// # Field-Level Attributes
/// - `prefix` – override struct-level prefix for this field
/// - `name` – override the argument name (defaults to the Rust field name)
/// - `delimiter` – override struct-level delimiter for this field
/// - `binary` – mark this field as the command executable (only one allowed)
/// - `transparent` – include the field value only, omit the argument name
/// - `flag` – include the field only if `true` (must be `bool`)
///
/// # Behavior
/// - Optional fields (`Option<T>`) are included only if `Some(value)`
/// - Arguments are formatted as `{prefix}{name}{delimiter}{value}`
/// - Field-level attributes override struct-level defaults
/// - Only one binary (struct-level or field-level) is allowed
///
/// # Example
///
/// ```rust,ignore
/// #[derive(ClapReverse)]
/// #[clap_reverse(display, binary = "echo")]
/// struct Echo {
/// #[clap_reverse(transparent)]
/// text: String,
/// #[clap_reverse(flag)]
/// loud: bool,
/// }
///
/// let echo = Echo { text: "Hello".into(), loud: true };
/// let cmd = echo.as_command();
/// println!("Command: `{echo}`"); // echo Hello --loud
/// ```