//! Staging-related command definitions.
//!
//! Commands for staging and unstaging files, hunks, and lines.

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

pub fn staging_commands() -> Vec<CommandDef> {
    vec![
        CommandDef {
            id: CommandId::StageSelected,
            name: "Stage file(s)",
            key: "s",
            category: CommandCategory::Staging,
            description: "Stage the selected file(s)",
            action_factory: |_| Some(Action::StageSelectedFile),
            is_enabled: |state| !state.status_selected_path.is_empty(),
            keywords: &["stage", "add", "file"],
        },
        CommandDef {
            id: CommandId::UnstageSelected,
            name: "Unstage file(s)",
            key: "u",
            category: CommandCategory::Staging,
            description: "Unstage the selected file(s)",
            action_factory: |_| Some(Action::UnstageSelectedFile),
            is_enabled: |state| !state.status_selected_path.is_empty(),
            keywords: &["unstage", "remove", "reset"],
        },
        CommandDef {
            id: CommandId::StageAll,
            name: "Stage all",
            key: "S",
            category: CommandCategory::Staging,
            description: "Stage all unstaged files",
            action_factory: |_| Some(Action::StageAllFiles),
            is_enabled: |_| true,
            keywords: &["stage", "all", "everything"],
        },
        CommandDef {
            id: CommandId::UnstageAll,
            name: "Unstage all",
            key: "U",
            category: CommandCategory::Staging,
            description: "Unstage all staged files",
            action_factory: |_| Some(Action::UnstageAllFiles),
            is_enabled: |_| true,
            keywords: &["unstage", "all", "reset"],
        },
        CommandDef {
            id: CommandId::StageHunk,
            name: "Stage hunk",
            key: "sh",
            category: CommandCategory::Staging,
            description: "Stage current hunk",
            action_factory: |_| Some(Action::StageCurrentHunk),
            is_enabled: |state| !state.hunks.is_empty(),
            keywords: &["stage", "hunk", "patch"],
        },
        CommandDef {
            id: CommandId::UnstageHunk,
            name: "Unstage hunk",
            key: "uh",
            category: CommandCategory::Staging,
            description: "Unstage current hunk",
            action_factory: |_| Some(Action::UnstageCurrentHunk),
            is_enabled: |state| !state.hunks.is_empty(),
            keywords: &["unstage", "hunk", "patch"],
        },
        CommandDef {
            id: CommandId::StageLines,
            name: "Stage selected lines",
            key: "sl",
            category: CommandCategory::Staging,
            description: "Stage selected lines",
            action_factory: |_| Some(Action::StageSelectedLines),
            is_enabled: |state| !state.selected_lines.is_empty(),
            keywords: &["stage", "lines", "selected"],
        },
        CommandDef {
            id: CommandId::UnstageLines,
            name: "Unstage selected lines",
            key: "ul",
            category: CommandCategory::Staging,
            description: "Unstage selected lines",
            action_factory: |_| Some(Action::UnstageSelectedLines),
            is_enabled: |state| !state.selected_lines.is_empty(),
            keywords: &["unstage", "lines", "selected"],
        },
    ]
}

