//! Merge-related command definitions.
//!
//! Commands for merge operations and merge notifier configuration.

use super::super::command::{CommandCategory, CommandDef, CommandId};
use crate::app::Action;

pub fn merge_commands() -> Vec<CommandDef> {
    vec![
        CommandDef {
            id: CommandId::MergeToggle,
            name: "Toggle merge notifier",
            key: "m",
            category: CommandCategory::MergeRebase,
            description: "Toggle merge notifier on/off",
            action_factory: |_| Some(Action::ToggleMergeNotifier),
            is_enabled: |_| true,
            keywords: &["merge", "notifier", "toggle"],
        },
        CommandDef {
            id: CommandId::MergeBase,
            name: "Set base branch (merge notifier)",
            key: "mb",
            category: CommandCategory::MergeRebase,
            description: "Set base branch for merge notifier",
            action_factory: |state| {
                let name = state.palette_input.trim().to_string();
                if !name.is_empty() {
                    Some(Action::SetMergeBaseBranch(name))
                } else {
                    None
                }
            },
            is_enabled: |_| true,
            keywords: &["merge", "base", "branch"],
        },
        CommandDef {
            id: CommandId::MergeInterval,
            name: "Set notifier interval (seconds)",
            key: "mi",
            category: CommandCategory::MergeRebase,
            description: "Set merge notifier interval in seconds",
            action_factory: |state| {
                let input = state.palette_input.trim();
                if let Ok(secs) = input.parse::<u64>() {
                    Some(Action::SetMergeInterval(secs))
                } else {
                    None
                }
            },
            is_enabled: |_| true,
            keywords: &["merge", "interval", "seconds", "notifier"],
        },
        CommandDef {
            id: CommandId::MergeCheck,
            name: "Check merge status now",
            key: "mc",
            category: CommandCategory::MergeRebase,
            description: "Manually check merge status",
            action_factory: |_| Some(Action::CheckMergeStatus),
            is_enabled: |_| true,
            keywords: &["merge", "check", "status"],
        },
        CommandDef {
            id: CommandId::MergeLog,
            name: "Merge notifier log",
            key: "mnl",
            category: CommandCategory::MergeRebase,
            description: "Show merge notifier log",
            action_factory: |_| Some(Action::ToggleMergeLog),
            is_enabled: |_| true,
            keywords: &["merge", "log", "notifier"],
        },
        CommandDef {
            id: CommandId::MergeBasePicker,
            name: "Pick merge base",
            key: "mbp",
            category: CommandCategory::MergeRebase,
            description: "Pick merge base from list",
            action_factory: |_| Some(Action::ShowMergeBasePicker),
            is_enabled: |_| true,
            keywords: &["merge", "base", "pick"],
        },
    ]
}

