//! Git operation command definitions.
//!
//! Commands for commits, cherry-picks, reverts, and other Git operations.

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

pub fn git_operations_commands() -> Vec<CommandDef> {
    vec![
        CommandDef {
            id: CommandId::Commit,
            name: "Commit staged",
            key: "c",
            category: CommandCategory::GitOperations,
            description: "Commit staged changes",
            action_factory: |_| Some(Action::StartCommit),
            is_enabled: |_| true,
            keywords: &["commit", "save", "staged"],
        },
        CommandDef {
            id: CommandId::Amend,
            name: "Amend last commit",
            key: "A",
            category: CommandCategory::GitOperations,
            description: "Amend the last commit",
            action_factory: |_| Some(Action::StartCommit),
            is_enabled: |_| true,
            keywords: &["amend", "modify", "last"],
        },
        CommandDef {
            id: CommandId::CherryPick,
            name: "Cherry-pick commit",
            key: "cp",
            category: CommandCategory::GitOperations,
            description: "Cherry-pick the selected commit",
            action_factory: |_| Some(Action::CherryPickSelected),
            is_enabled: |state| !state.commits.is_empty() && state.commit_selected < state.commits.len(),
            keywords: &["cherry", "pick", "commit"],
        },
        CommandDef {
            id: CommandId::Revert,
            name: "Revert commit",
            key: "rv",
            category: CommandCategory::GitOperations,
            description: "Revert the selected commit",
            action_factory: |_| Some(Action::RevertSelected),
            is_enabled: |state| !state.commits.is_empty() && state.commit_selected < state.commits.len(),
            keywords: &["revert", "undo", "commit"],
        },
        CommandDef {
            id: CommandId::ShowOpLog,
            name: "Show op log",
            key: "o",
            category: CommandCategory::GitOperations,
            description: "Show operation log",
            action_factory: |_| Some(Action::ToggleOpLog),
            is_enabled: |_| true,
            keywords: &["log", "operations", "history"],
        },
        CommandDef {
            id: CommandId::MergedList,
            name: "List merged branches",
            key: "ml",
            category: CommandCategory::GitOperations,
            description: "List branches that have been merged",
            action_factory: |_| Some(Action::ListMergedBranches),
            is_enabled: |_| true,
            keywords: &["merged", "branches", "list"],
        },
        CommandDef {
            id: CommandId::MergedPrune,
            name: "Prune merged branches",
            key: "pm",
            category: CommandCategory::GitOperations,
            description: "Prune merged branches (with confirmation)",
            action_factory: |_| Some(Action::RequestPruneMergedBranches),
            is_enabled: |_| true,
            keywords: &["prune", "merged", "branches"],
        },
        CommandDef {
            id: CommandId::CreateBranch,
            name: "Create new branch",
            key: "B",
            category: CommandCategory::GitOperations,
            description: "Create a new branch",
            action_factory: |_| Some(Action::StartBranchCreate),
            is_enabled: |_| true,
            keywords: &["branch", "create", "new"],
        },
        CommandDef {
            id: CommandId::CreateStash,
            name: "Create stash",
            key: "S",
            category: CommandCategory::GitOperations,
            description: "Create a new stash with optional message",
            action_factory: |_| Some(Action::StartStashCreate),
            is_enabled: |_| true,
            keywords: &["stash", "create", "save", "push"],
        },
    ]
}

