use crate::app::{App, branch_scope};
use crate::git::git_capture;
use std::io::{self, IsTerminal};
#[derive(clap::Args)]
pub struct Args {
#[arg(short, long)]
pub all: bool,
#[arg(short, long)]
pub remotes: bool,
}
pub fn run(args: Args) {
if !io::stdout().is_terminal() {
eprintln!(
"slu ibranch needs an interactive terminal - use `slu tidy` / `git branch` instead"
);
return;
}
let repo =
git_capture(".", &["rev-parse", "--show-toplevel"]).unwrap_or_else(|| ".".to_string());
match App::at_branches(repo, branch_scope(args.all, args.remotes)) {
Some(app) => app.run("ibranch"),
None => eprintln!("no branches (or not a git repo)"),
}
}