pub mod git_commands;
pub mod custom;
pub mod patch;
pub mod branch;
pub mod stash;
#[cfg(test)]
pub mod test_utils;

pub use git_commands::{
    StageFilesCommand,
    UnstageFilesCommand,
    CommitCommand,
    PushCommand,
    CherryPickCommand,
    RevertCommand,
    RebaseContinueCommand,
    RebaseAbortCommand,
    RebaseSkipCommand,
    ResetCommand,
    ListMergedBranchesCommand,
    PruneMergedBranchesCommand,
    RemotePruneCommand,
    ShowRemoteUrlCommand,
    SetRemoteSshCommand,
    AutoFetchCommand,
    RebaseTodoLoadCommand,
    RebaseTodoOpenCommand,
    RebaseTodoSaveCommand,
    PrListCommand,
    PrCheckoutCommand,
    PrOpenCommand,
    LogBriefCommand,
    LogStatsCommand,
    PullCommand,
    PullRebaseCommand,
    OpenInEditorCommand,
    CheckMergeStatusCommand,
};
pub use patch::{
    StageHunkCommand,
    UnstageHunkCommand,
    StageLinesCommand,
    UnstageLinesCommand,
};
pub use branch::{CheckoutBranchCommand, MergeBranchCommand, RebaseBranchCommand, CreateBranchCommand};
pub use stash::{ApplyStashCommand, PopStashCommand, CreateStashCommand, DeleteStashCommand};
#[cfg(test)]
#[allow(unused_imports)]
pub use test_utils::*;

use crate::services::GitService;
use crate::app::AppState;
use crate::errors::CommandError;

/// Command trait for executing side effects (git operations)
pub trait Command: Send + Sync {
    /// Execute the command
    fn execute(
        &self,
        git: &GitService,
        state: &AppState,
    ) -> Result<CommandResult, CommandError>;
}

/// Result of command execution
#[derive(Debug)]
pub enum CommandResult {
    /// State update to apply
    StateUpdate(AppState),
    /// Async task spawned (handled separately)
    #[allow(dead_code)]
    AsyncTask(crate::app::state::AsyncTask),
    /// No state change needed
    #[allow(dead_code)]
    NoOp,
}
