mod common;
mod linear;
mod quota;
mod timefmt;
use std::process::ExitCode;
use clap::Parser;
use common::Error;
const EXIT_ERROR: u8 = 1;
const EXIT_RATE_LIMITED: u8 = 2;
#[derive(Parser)]
#[command(name = "atb", version, about)]
struct Cli {
#[command(subcommand)]
tool: Tool,
}
#[derive(clap::Subcommand)]
enum Tool {
Quota(quota::Args),
Linear(linear::Args),
}
fn main() -> ExitCode {
let result = match Cli::parse().tool {
Tool::Quota(args) => quota::run(args).map(|()| 0),
Tool::Linear(args) => linear::run(args),
};
match result {
Ok(code) => ExitCode::from(code),
Err(err) => {
eprintln!("error: {err}");
ExitCode::from(match err {
Error::RateLimited { .. } => EXIT_RATE_LIMITED,
Error::Usage(_) => EXIT_ERROR,
})
}
}
}