codex_usage 0.1.1

Codex and Claude Code telemetry/usage parser, aggregate JSONL events into CodeAnalysis results
Documentation
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;

/// Get git remote origin URL from a directory
pub fn get_git_remote_url<P: AsRef<Path>>(cwd: P) -> String {
    let git_config = cwd.as_ref().join(".git").join("config");

    let file = match File::open(&git_config) {
        Ok(f) => f,
        Err(_) => return String::new(),
    };

    let reader = BufReader::new(file);
    let mut in_origin_section = false;

    for line in reader.lines().map_while(Result::ok) {
        let trimmed = line.trim();

        // Check for section headers
        if trimmed.starts_with('[') && trimmed.ends_with(']') {
            in_origin_section = trimmed.starts_with("[remote \"origin\"");
            continue;
        }

        // Look for url in origin section
        if in_origin_section && trimmed.starts_with("url = ") {
            return trimmed.trim_start_matches("url = ").trim().to_string();
        }
    }

    String::new()
}