sluuz 0.10.2

git, but it sleuths - a git superset with cross-repo search, secret scanning, and multi-repo management
//! `slu irepos` - interactive repo explorer (TUI). The top of the drill: every
//! repo under a path, then its branches, its commits, and their diffs.
//!
//! Repos (top, j/k) preview the selected one's branches below (Ctrl-j/k), with
//! the same state flags `slu repos` prints, so the list doubles as a dashboard.
//! `h`/`l` move between the all, dirty and unpushed tabs. Enter drills in,
//! Esc steps back, and quits here.

use crate::app::{App, repo_scope};
use crate::git::no_repos;
use std::io::{self, IsTerminal};
use std::path::PathBuf;

#[derive(clap::Args)]
pub struct Args {
    /// Base directory to search for repos (defaults to current directory)
    #[arg(default_value = ".")]
    pub path: PathBuf,

    /// How many directory levels deep to look for repos
    #[arg(short, long, default_value_t = 3)]
    pub depth: usize,

    /// Start on the repos with uncommitted work
    #[arg(long)]
    pub dirty: bool,
}

pub fn run(args: Args) {
    if !io::stdout().is_terminal() {
        eprintln!("slu irepos needs an interactive terminal - use `slu repos` for plain output");
        return;
    }

    match App::at_repos(&args.path, args.depth, repo_scope(args.dirty)) {
        Some(app) => app.run("irepos"),
        None => {
            eprintln!("{}", no_repos(&args.path, args.depth));
            std::process::exit(1);
        }
    }
}