get_git_command

Function get_git_command 

Source
pub const fn get_git_command() -> &'static str
Expand description

Returns the appropriate Git command name for the current platform.

This function returns the platform-specific Git executable name that should be used when invoking Git commands via the system shell.

§Returns

  • "git.exe" on Windows
  • "git" on Unix-like systems (macOS, Linux, BSD)

§Examples

use agpm_cli::utils::platform::get_git_command;
use std::process::Command;

let git_cmd = get_git_command();
let output = Command::new(git_cmd)
    .args(["--version"])
    .output()?;

println!("Git version: {}", String::from_utf8_lossy(&output.stdout));

§Platform Differences

  • Windows: Uses git.exe to explicitly invoke the executable
  • Unix-like: Uses git which relies on PATH resolution

§Note

This function returns the command name, not the full path. The actual Git executable must still be available in the system PATH for commands to succeed.

§See Also

  • command_exists to check if Git is available
  • System PATH configuration for Git availability