generated from Patagia/template-nix
parent
ac6a53fac9
commit
a4097b7cc3
14 changed files with 268 additions and 78 deletions
xtask
15
xtask/Cargo.toml
Normal file
15
xtask/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "xtask"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "xtask"
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
patagia-controller = { path = "../controller" }
|
||||
semver.workspace = true
|
30
xtask/src/main.rs
Normal file
30
xtask/src/main.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
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(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue