grit/command/
root.rs

1use std::ffi;
2
3use crate::{
4    error::{Error, Result},
5    git::git,
6};
7
8/// Prints the repository root directory.
9///
10/// # Errors
11///
12/// Returns an error if Git fails, or if `args` is nonempty.
13pub async fn root(mut args: impl Iterator<Item = ffi::OsString>) -> Result<()> {
14    if let Some(arg) = args.next() {
15        return Err(Error::Arg(arg));
16    }
17    print!("{}", git(["rev-parse", "--show-toplevel"]).await?);
18    Ok(())
19}