1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
use toml::Value;
mod document;
pub use document::*;
pub const YARNER_VERSION: &str = env!(
"CARGO_PKG_VERSION",
"Environmental variable CARGO_PKG_VERSION not found"
);
#[derive(Debug, Serialize, Deserialize)]
pub struct YarnerData {
pub context: Context,
pub documents: HashMap<PathBuf, Document>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Context {
pub config: Value,
pub name: String,
pub yarner_version: String,
}
pub fn parse_input() -> serde_json::Result<YarnerData> {
serde_json::from_reader(std::io::stdin())
}
pub fn write_output(data: &YarnerData) -> serde_json::Result<()> {
println!("{}", serde_json::to_string_pretty(data)?);
Ok(())
}