use clap::Command;
mod cli;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let modules = crate::cli::all();
if modules.is_empty() {
eprintln!("No troll modules enabled.");
eprintln!("Build with at least one feature, e.g. `--features window-hider`.");
std::process::exit(2);
}
let mut root = Command::new("windows-troll")
.version(env!("CARGO_PKG_VERSION"))
.about("A collection of harmless Windows pranks")
.propagate_version(true)
.subcommand_required(true)
.arg_required_else_help(true);
for module in &modules {
root = root.subcommand(module.command());
}
let matches = root.get_matches();
let (name, sub_matches) = matches.subcommand().expect("subcommand is required");
for module in &modules {
if module.name() == name {
return module.run(sub_matches);
}
}
Err(format!("unknown subcommand: {name}").into())
}