git-alias 1.2.11

A fast git alias tool with dual-style command support
use std::process::Command;

pub fn execute_git_command(args: &[String]) -> i32 {
    let mut git_args = vec![
        "-c".to_string(),
        "color.status=always".to_string(),
        "-c".to_string(),
        "color.diff=always".to_string(),
        "-c".to_string(),
        "color.branch=always".to_string(),
        "-c".to_string(),
        "color.ui=always".to_string(),
    ];
    git_args.extend_from_slice(args);

    let status = Command::new("git")
        .args(&git_args)
        .status();

    match status {
        Ok(status) => status.code().unwrap_or(1),
        Err(e) => {
            eprintln!("Failed to execute git: {}", e);
            1
        }
    }
}

/// Execute a git command and return its stdout as a String
pub fn exec_git_output(args: &[&str]) -> String {
    let output = Command::new("git").args(args).output();
    match output {
        Ok(o) => String::from_utf8_lossy(&o.stdout).to_string(),
        Err(e) => {
            eprintln!("Failed to execute git: {}", e);
            String::new()
        }
    }
}