2022-08-04 22:24:25 +01:00
|
|
|
#![deny(clippy::all)]
|
2022-08-04 21:30:02 +01:00
|
|
|
use clap::Command;
|
2022-08-04 20:28:14 +01:00
|
|
|
|
2022-08-04 20:29:01 +01:00
|
|
|
mod publish;
|
2022-10-01 20:21:15 +01:00
|
|
|
mod release;
|
2022-10-01 20:36:42 +01:00
|
|
|
mod utils;
|
2022-08-04 20:29:01 +01:00
|
|
|
|
2022-10-01 20:30:45 +01:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
PublishError(publish::Error),
|
|
|
|
ReleaseError(release::Error),
|
|
|
|
}
|
|
|
|
|
2022-10-01 19:44:21 +01:00
|
|
|
fn cli() -> Command {
|
|
|
|
Command::new("Agb tools")
|
2022-08-04 20:28:14 +01:00
|
|
|
.subcommand_required(true)
|
|
|
|
.arg_required_else_help(true)
|
2022-08-04 21:36:24 +01:00
|
|
|
.subcommand(publish::command())
|
2022-10-01 20:21:15 +01:00
|
|
|
.subcommand(release::command())
|
2022-10-01 19:44:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let matches = cli().get_matches();
|
2022-08-04 20:28:14 +01:00
|
|
|
|
2022-08-04 21:10:11 +01:00
|
|
|
let result = match matches.subcommand() {
|
2022-10-01 20:30:45 +01:00
|
|
|
Some(("publish", arg_matches)) => {
|
|
|
|
publish::publish(arg_matches).map_err(Error::PublishError)
|
|
|
|
}
|
|
|
|
|
|
|
|
Some(("release", arg_matches)) => {
|
|
|
|
release::release(arg_matches).map_err(Error::ReleaseError)
|
|
|
|
}
|
|
|
|
|
2022-08-04 20:28:14 +01:00
|
|
|
_ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"),
|
2022-08-04 21:10:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if let Err(e) = result {
|
2023-02-07 20:32:43 +00:00
|
|
|
eprintln!("Error: {e:?}");
|
2022-08-04 20:28:14 +01:00
|
|
|
}
|
|
|
|
}
|
2022-10-01 19:44:21 +01:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn verify_cli() {
|
|
|
|
cli().debug_assert();
|
|
|
|
}
|
|
|
|
}
|