mirror of
https://github.com/BrianHicks/elm-duet.git
synced 2024-10-26 14:10:36 +03:00
add basic schema struct
This commit is contained in:
parent
80bed6eb8d
commit
a130a40620
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -220,6 +220,8 @@ dependencies = [
|
||||
"color-eyre",
|
||||
"eyre",
|
||||
"jtd",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
|
@ -10,4 +10,6 @@ clap = { version = "4.5.4", features = ["derive"] }
|
||||
color-eyre = "0.6.3"
|
||||
eyre = "0.6.12"
|
||||
jtd = "0.3.1"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
serde_json = "1.0.115"
|
||||
tracing = "0.1.40"
|
||||
|
@ -1,5 +1,8 @@
|
||||
mod schema;
|
||||
|
||||
use clap::Parser;
|
||||
use eyre::Result;
|
||||
use color_eyre::Result;
|
||||
use eyre::WrapErr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
@ -11,6 +14,10 @@ struct Cli {
|
||||
impl Cli {
|
||||
fn run(&self) -> Result<()> {
|
||||
println!("{self:#?}");
|
||||
|
||||
let schema = schema::Schema::from_fs(&self.source).wrap_err("could not read schema")?;
|
||||
println!("{schema:#?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
15
src/schema.rs
Normal file
15
src/schema.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use color_eyre::Result;
|
||||
use eyre::WrapErr;
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Schema {}
|
||||
|
||||
impl Schema {
|
||||
pub fn from_fs(path: &Path) -> Result<Schema> {
|
||||
let bytes = std::fs::read(path).wrap_err_with(|| format!("could not read {path:?}"))?;
|
||||
serde_json::from_slice(&bytes)
|
||||
.wrap_err_with(|| format!("could not read schema from {path:?}"))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user