//! Configuration command definitions.
//!
//! Commands for configuring pull, rebase, theme, and other settings.

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

pub fn configuration_commands() -> Vec<CommandDef> {
    vec![
        CommandDef {
            id: CommandId::PullTimeout,
            name: "Set pull timeout (seconds)",
            key: "pt",
            category: CommandCategory::Configuration,
            description: "Set pull timeout in seconds",
            action_factory: |state| {
                let input = state.palette_input.trim();
                if let Ok(secs) = input.parse::<u64>() {
                    Some(Action::SetPullTimeout(secs))
                } else {
                    None
                }
            },
            is_enabled: |_| true,
            keywords: &["pull", "timeout", "seconds"],
        },
        CommandDef {
            id: CommandId::RebaseTimeout,
            name: "Set rebase timeout (seconds)",
            key: "rto",
            category: CommandCategory::Configuration,
            description: "Set rebase timeout in seconds",
            action_factory: |state| {
                let input = state.palette_input.trim();
                if let Ok(secs) = input.parse::<u64>() {
                    Some(Action::SetRebaseTimeout(secs))
                } else {
                    None
                }
            },
            is_enabled: |_| true,
            keywords: &["rebase", "timeout", "seconds"],
        },
        CommandDef {
            id: CommandId::ToggleFfOnly,
            name: "Toggle ff-only",
            key: "ff",
            category: CommandCategory::Configuration,
            description: "Toggle fast-forward only for pull",
            action_factory: |_| Some(Action::ToggleFFOnly),
            is_enabled: |_| true,
            keywords: &["ff", "only", "fast", "forward"],
        },
        CommandDef {
            id: CommandId::ToggleAutostash,
            name: "Toggle autostash",
            key: "as",
            category: CommandCategory::Configuration,
            description: "Toggle autostash for pull --rebase",
            action_factory: |_| Some(Action::ToggleAutostash),
            is_enabled: |_| true,
            keywords: &["autostash", "stash", "toggle"],
        },
        CommandDef {
            id: CommandId::TogglePushFf,
            name: "Toggle push ff-only guard",
            key: "pf",
            category: CommandCategory::Configuration,
            description: "Toggle push fast-forward only guard",
            action_factory: |_| Some(Action::TogglePushFFOnly),
            is_enabled: |_| true,
            keywords: &["push", "ff", "guard"],
        },
        CommandDef {
            id: CommandId::ReloadTheme,
            name: "Reload theme",
            key: "T",
            category: CommandCategory::Configuration,
            description: "Reload theme from config",
            action_factory: |_| Some(Action::ReloadTheme),
            is_enabled: |_| true,
            keywords: &["reload", "theme"],
        },
        CommandDef {
            id: CommandId::SwitchTheme,
            name: "Switch theme",
            key: "t",
            category: CommandCategory::Configuration,
            description: "Switch theme",
            action_factory: |_| Some(Action::ShowThemePicker),
            is_enabled: |_| true,
            keywords: &["switch", "theme", "change"],
        },
    ]
}

