WIP
This commit is contained in:
23
crete/src/bin/schemas.rs
Normal file
23
crete/src/bin/schemas.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use std::{fs::File, io::Write};
|
||||
|
||||
use crete::{cluster::Cluster, node::OptionalNode};
|
||||
use repo_path_lib::repo_dir;
|
||||
use schemars::{JsonSchema, schema_for};
|
||||
|
||||
fn write<T>(name: &str)
|
||||
where
|
||||
T: JsonSchema,
|
||||
{
|
||||
let mut path = repo_dir().join("schemas").join(name);
|
||||
path.add_extension("json");
|
||||
let mut file = File::create(path).unwrap();
|
||||
|
||||
let schema = serde_json::to_string_pretty(&schema_for!(T)).unwrap();
|
||||
file.write_all(schema.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
// TODO: Create directory if it does not exist
|
||||
fn main() {
|
||||
write::<Cluster>("cluster");
|
||||
write::<OptionalNode>("node");
|
||||
}
|
||||
Reference in New Issue
Block a user