args-cli 0.1.1

Command-line interface for args
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const CONFIG_FILENAME: &str = ".args-ci.toml";

/// Returns the path to .args-ci.toml in the git repo root.
/// Does not check whether the file exists.
pub async fn find_config() -> anyhow::Result<std::path::PathBuf> {
    let output = tokio::process::Command::new("git")
        .args(["rev-parse", "--show-toplevel"])
        .output()
        .await?;

    if !output.status.success() {
        anyhow::bail!("Not inside a git repository");
    }

    let git_root = std::path::PathBuf::from(String::from_utf8(output.stdout)?.trim());
    Ok(git_root.join(CONFIG_FILENAME))
}