use clap::{Args, Subcommand};

#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
#[command(about = "Manage ring members")]
#[command(flatten_help = true)]
pub struct MemberArgs {
    #[command(subcommand)]
    pub command: Option<MemberCommands>,
}

#[derive(Debug, Subcommand)]
pub enum MemberCommands {
    #[command(about = "List members")]
    List {
        #[arg(
            help = "Ring URL (default if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,
    },

    #[command(about = "Enroll new member to ring", alias = "add")]
    Enroll {
        #[arg(
            help = "Ring URL (default if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,

        #[arg(help = "Member Name", short = 'n', long = "name", required = false)]
        name: Option<String>,

        #[arg(
            help = "Member Description",
            short = 'd',
            long = "description",
            required = false
        )]
        description: Option<String>,

        #[arg(help = "Member Url", short = 'u', long = "url", required = false)]
        url: Option<String>,

        #[arg(
            help = "Member Public Signing Key",
            short = 'k',
            long = "public-signing-key",
            required = false
        )]
        public_signing_key: Option<String>,
    },

    #[command(about = "Unenroll member from ring", alias = "delete")]
    Unenroll {
        #[arg(help = "Member URL", short = 'u', long = "url", required = true)]
        url: String,

        #[arg(
            help = "Ring URL (default ring if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,
    },

    #[command(about = "Rotate Member public key")]
    Rotate {
        #[arg(help = "Member URL", short = 'u', long = "url", required = true)]
        url: String,

        #[arg(
            help = "Ring URL (default ring if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,

        #[arg(help = "New public key", short = 'k', long = "key", required = true)]
        new_key: String,
    },

    #[command(about = "Get Member Standing")]
    Standing {
        #[arg(
            help = "Ring URL (default if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,

        #[arg(help = "Member URL", short = 'u', long = "member-url", required = true)]
        member_url: String,
    },

    #[command(about = "Get Member Standing")]
    VerifyManifest {
        #[arg(
            help = "Ring URL (default if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,

        #[arg(help = "Member URL", short = 'u', long = "member-url", required = true)]
        member_url: String,
    },
}
