//! Remote operation command definitions.
//!
//! Commands for push, pull, and remote repository management.

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

pub fn remote_commands() -> Vec<CommandDef> {
    vec![
        CommandDef {
            id: CommandId::Push,
            name: "Push",
            key: "P",
            category: CommandCategory::Remote,
            description: "Push current branch to remote",
            action_factory: |_| Some(Action::Push),
            is_enabled: |_| true,
            keywords: &["push", "upload", "remote"],
        },
        CommandDef {
            id: CommandId::Pull,
            name: "Pull (ff-only)",
            key: "pl",
            category: CommandCategory::Remote,
            description: "Pull with fast-forward only",
            action_factory: |_| Some(Action::Pull),
            is_enabled: |_| true,
            keywords: &["pull", "fetch", "update"],
        },
        CommandDef {
            id: CommandId::PullRebase,
            name: "Pull --rebase",
            key: "pr",
            category: CommandCategory::Remote,
            description: "Pull with rebase",
            action_factory: |_| Some(Action::PullRebase),
            is_enabled: |_| true,
            keywords: &["pull", "rebase", "update"],
        },
        CommandDef {
            id: CommandId::RemotePrune,
            name: "Remote prune (confirm)",
            key: "rp",
            category: CommandCategory::Remote,
            description: "Prune remote branches (with confirmation)",
            action_factory: |state| {
                if !state.remotes.is_empty() {
                    Some(Action::RequestRemotePrune(state.remotes[0].name.clone()))
                } else {
                    None
                }
            },
            is_enabled: |state| !state.remotes.is_empty(),
            keywords: &["remote", "prune", "cleanup"],
        },
        CommandDef {
            id: CommandId::ShowRemoteUrl,
            name: "Show remote URL",
            key: "ru",
            category: CommandCategory::Remote,
            description: "Show remote URL",
            action_factory: |state| {
                if !state.remotes.is_empty() {
                    Some(Action::ShowRemoteUrl(state.remotes[0].name.clone()))
                } else {
                    None
                }
            },
            is_enabled: |state| !state.remotes.is_empty(),
            keywords: &["remote", "url", "show"],
        },
        CommandDef {
            id: CommandId::SetRemoteSsh,
            name: "Set remote to SSH",
            key: "rs",
            category: CommandCategory::Remote,
            description: "Set remote URL to SSH format",
            action_factory: |state| {
                if !state.remotes.is_empty() {
                    Some(Action::SetRemoteSsh(state.remotes[0].name.clone()))
                } else {
                    None
                }
            },
            is_enabled: |state| !state.remotes.is_empty(),
            keywords: &["remote", "ssh", "set"],
        },
    ]
}

