use clap::{ArgAction, Args, Subcommand};

#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
#[command(about = "Manage Ringspace rings")]
#[command(flatten_help = true)]
pub struct RingArgs {
    #[command(subcommand)]
    pub command: Option<RingCommands>,
}

#[derive(Debug, Subcommand)]
pub enum RingCommands {
    #[command(about = "Create a new ring", alias = "add")]
    Create {
        #[arg(help = "Ring Name", short = 'n', long = "name", required = false)]
        name: Option<String>,

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

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

        #[arg(
            help = "Set as default",
            short = 'f',
            long = "default",
            action = ArgAction::SetTrue
        )]
        default_ring: bool,
    },

    #[command(about = "List rings")]
    List,
    #[command(about = "Get ring by URL")]
    Get {
        #[arg(help = "Ring URL", short = 'r', long = "ring-url", required = false)]
        ring_url: Option<String>,
    },
    #[command(about = "Delete ring")]
    Delete {
        #[arg(help = "Ring URL", short = 'r', long = "ring-url", required = true)]
        ring_url: String,
    },

    #[command(about = "Set default ring")]
    SetDefault {
        #[arg(help = "Ring URL", short = 'r', long = "ring-url", required = true)]
        ring_url: String,
    },

    #[command(about = "Decrypt a single base64-encoded vote from a site")]
    DecryptVote {
        #[arg(
            help = "Ring URL (default if omitted)",
            short = 'r',
            long = "ring-url",
            required = false
        )]
        ring_url: Option<String>,

        #[arg(
            help = "Base64-encoded encrypted vote",
            short = 'v',
            long = "encrypted-vote",
            required = true
        )]
        encrypted_vote: String,
    },

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

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