use clap::{Parser, Subcommand};
pub mod invite;
pub mod member;
pub mod ring;
pub mod site;
use invite::*;
use member::*;
use ring::*;
use site::*;

#[derive(Debug, Parser)] // requires `derive` feature
#[command(name = "ringspace")]
#[command(about = "Trusted webring management", long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Debug, Subcommand)]
pub enum Commands {
    #[command(about = "Manage a Ringspace Ring", arg_required_else_help = true)]
    Ring(RingArgs),

    #[command(
        about = "Manage Ring Members (as a Ring manager)",
        arg_required_else_help = true
    )]
    Member(MemberArgs),

    #[command(
        about = "Manage a Ringspace Sites (as a site owner)",
        arg_required_else_help = true
    )]
    Site(SiteArgs),

    #[command(about = "Launch the Ringspace Server")]
    Server {
        #[arg(help = "Server port", short = 'p', long = "port", required = false)]
        port: Option<usize>,

        #[arg(
            help = "Server address",
            short = 'a',
            long = "address",
            required = false
        )]
        address: Option<String>,

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

    #[command(about = "Manage Invites", arg_required_else_help = true)]
    Invite(InviteArgs),

    #[command(about = "Generate an encryption keypair")]
    Enckey,

    #[command(about = "Generate a signing keypair")]
    Signkey,

    #[command(about = "Perform any necessary database migrations between versions")]
    Migrate,
}
