mod backend;
mod commands;
mod engine;
mod model;
use clap::{Parser, Subcommand};
const EXAMPLES: &str = "\x1b[1mExamples:\x1b[0m
whypkg Browse every installed package
whypkg --upgradable Browse only packages with a pending upgrade
whypkg pending Report every pending upgrade, grouped by why it's here
whypkg pending --quick One line per pending package: size + reason
whypkg update Update whypkg to the latest release
Inside the browser: type to filter, Enter to open, Esc to go back.";
#[derive(Parser)]
#[command(
name = "whypkg",
bin_name = "whypkg",
version,
about = "why the hell is this package here? — a fast, cross-distro package investigator",
after_help = EXAMPLES,
)]
struct Cli {
#[command(subcommand)]
command: Option<Cmd>,
#[arg(long, global = true)]
upgradable: bool,
}
#[derive(Subcommand)]
enum Cmd {
Pending(commands::pending::Args),
Update(commands::update::Args),
}
fn main() {
let cli = Cli::parse();
match cli.command {
Some(Cmd::Pending(args)) => commands::pending::run(args),
Some(Cmd::Update(args)) => commands::update::run(args),
None => commands::browse::run(commands::browse::Args {
upgradable: cli.upgradable,
}),
}
}