patagia-control/xtask/src/main.rs
Daniel Lundin a4097b7cc3
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Add OpenAPI generation xtask
2024-12-14 17:18:29 +01:00

30 lines
604 B
Rust

use anyhow::Result;
use clap::Parser;
use patagia_controller::api;
#[derive(Debug, Parser)]
#[command(name = "cargo xtask", about = "Extra tasks for Patagia Controller")]
enum Xtask {
/// Generate OpenAPI spec
OpenApi,
}
fn gen_openapi() -> Result<()> {
let api = api::api()?;
let openapi = api.openapi("Patagia Controller", semver::Version::new(1, 0, 0));
openapi.write(&mut std::io::stdout().lock())?;
Ok(())
}
fn main() -> Result<()> {
let xtask = Xtask::parse();
match xtask {
Xtask::OpenApi => {
gen_openapi()?;
}
}
Ok(())
}