//! Governance CLI command definitions.

use clap::Subcommand;

#[derive(Subcommand)]
pub enum GovernanceCommands {
    /// List pending approval requests
    ///
    /// Shows all patterns awaiting approval, grouped by workflow and stage.
    Pending {
        /// Filter by workflow name
        #[arg(long)]
        workflow: Option<String>,

        /// Output format: table or json
        #[arg(short, long, default_value = "table")]
        format: String,
    },

    /// Approve the current stage of a request
    ///
    /// Advances the request to the next stage, or completes approval
    /// if this was the final stage.
    Approve {
        /// Request ID (UUID format)
        id: String,

        /// Optional comment explaining the approval
        #[arg(short, long)]
        comment: Option<String>,
    },

    /// Reject a pending request
    ///
    /// Marks the request as rejected. The pattern will not be promoted
    /// until a new approval request is created.
    Reject {
        /// Request ID (UUID format)
        id: String,

        /// Reason for rejection (required)
        #[arg(short, long)]
        reason: String,
    },

    /// Escalate a request to the next stage
    ///
    /// Manually escalates a request to its configured escalation target.
    /// Use this when a stage is taking too long or needs higher-level review.
    Escalate {
        /// Request ID (UUID format)
        id: String,
    },

    /// Show approval request status
    ///
    /// Display detailed status for approval requests, including
    /// decisions made and current stage.
    Status {
        /// Show status for a specific pattern (UUID format)
        #[arg(long)]
        pattern: Option<String>,

        /// Show all requests (including completed)
        #[arg(long)]
        all: bool,

        /// Output format: table or json
        #[arg(short, long, default_value = "table")]
        format: String,
    },

    /// Check for timed-out requests and process them
    ///
    /// Scans for requests past their stage deadline and either
    /// escalates or expires them based on workflow configuration.
    CheckTimeouts,

    /// Create an approval request for a pattern
    ///
    /// Manually create an approval request for a pattern. Normally
    /// requests are created automatically during promotion.
    Create {
        /// Pattern ID (UUID format)
        pattern_id: String,

        /// Workflow to use (defaults to config default_workflow)
        #[arg(short, long)]
        workflow: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum AuditCommands {
    /// Show audit trail for a pattern
    ///
    /// Displays all governance events for a pattern in chronological order.
    Trail {
        /// Pattern ID (UUID format)
        #[arg(long)]
        pattern: String,

        /// Output format: table or json
        #[arg(short, long, default_value = "table")]
        format: String,
    },

    /// Export governance audit history
    ///
    /// Export all governance events and requests to a file for
    /// compliance reporting or external analysis.
    Export {
        /// Output file path
        #[arg(short, long)]
        output: std::path::PathBuf,

        /// Export format: json, csv, or markdown
        #[arg(short, long, default_value = "json")]
        format: String,

        /// Filter by date range (YYYY-MM-DD..YYYY-MM-DD)
        #[arg(long)]
        date_range: Option<String>,
    },

    /// Show audit summary statistics
    ///
    /// Display summary of governance activity including
    /// approval rates, average times, and pending counts.
    Summary {
        /// Output format: table or json
        #[arg(short, long, default_value = "table")]
        format: String,
    },
}
