void-cli 0.0.3

CLI for void — anonymous encrypted source control
//! Graph command — interactive commit graph visualization.
//!
//! Calls the `void-graph` library directly for full terminal control.

use std::path::Path;

use camino::Utf8PathBuf;
use void_graph::void_backend::SortOrder;

use crate::context::open_repo;
use crate::output::{CliError, CliOptions};

/// Run the graph command by calling void-graph as a library.
pub fn run(cwd: &Path, max_count: usize, order: &str, _opts: &CliOptions) -> Result<(), CliError> {
    let path = Utf8PathBuf::from_path_buf(cwd.to_path_buf())
        .map_err(|_| CliError::invalid_args("path is not valid UTF-8"))?;
    let order = match order {
        "topo" => SortOrder::Topological,
        _ => SortOrder::Chronological,
    };

    // Build full repo context; extract vault for TUI
    let repo = open_repo(cwd)?;
    let vault = repo.vault().clone();

    void_graph::app::run(&path, max_count, order, vault)
        .map_err(|e| CliError::internal(format!("graph: {}", e)))
}