git-root 0.1.0

A humble wrapper that makes finding the git project root directory trivial and installable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extern crate failure;
use std::process::{Command};
use std::str;

fn main() -> Result<(), failure::Error> {
    let output = Command::new("git")
        .args(&["rev-parse", "--show-toplevel"])
        .output()?;
    if output.status.success() {
        print!("{}", str::from_utf8(&output.stdout)?);
    } else {
        eprint!("{}", str::from_utf8(&output.stderr)?);
    }
    Ok(())
}