Skip to content

Support nested derive macros #15

Open
@MrFoxPro

Description

@MrFoxPro
use clap::Parser;
use std::net::SocketAddr;

structstruck::strike! {
#[structstruck::each[derive(Clone, Debug)]]
#[derive(clap::Parser)]
#[command(disable_help_subcommand = true, disable_help_flag = true)]
pub struct Input {
	#[command(subcommand)]
	pub mode: #[derive(clap::Subcommand)] pub enum Mode {
		Server(#[derive(clap::Args)] pub struct ServerArgs {
			#[arg(long, value_name = "IP:PORT")]
			listen: Option<SocketAddr>,
		}),
		Client(#[derive(clap::Args)] pub struct ClientArgs {
			#[arg(long, value_name = "IP:PORT")]
			connect: SocketAddr,

			#[arg(long, value_name = "IP")]
			bind: Option<Ipv4Addr>,

			#[arg(long, value_name = "SECONDS")]
			duration_sec: Option<u32>,

			#[arg(long, value_name = "PROTOCOL")]
			protocol: Option<#[derive(clap::ValueEnum, Default)] pub enum Protocol { Udp, #[default] Tcp }>,
		}),
	},
}}
error: expected non-macro attribute, found attribute macro `derive`
  --> root/config.rs:96:12
   |
96 |         Server(#[derive(clap::Args)] pub struct ServerArgs {
   |                  ^^^^^^ not a non-macro attribute

error: expected non-macro attribute, found attribute macro `derive`
   --> root/config.rs:100:12
    |
100 |         Client(#[derive(clap::Args)] pub struct ClientArgs {
    |                  ^^^^^^ not a non-macro attribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions