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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
pub mod theme;
#[cfg(feature = "io")]
pub mod io;
pub use theme::{Colors, Palette, Theme};
pub use serde_json;
#[cfg(feature = "palette")]
pub use palette;
#[cfg(not(feature = "palette"))]
pub mod palette {
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Srgb<T = f32> {
pub red: T,
pub green: T,
pub blue: T,
}
impl<T> Srgb<T> {
pub const fn new(red: T, green: T, blue: T) -> Self {
Self { red, green, blue }
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Directories {
pub config: PathBuf,
pub output: PathBuf,
pub cache: PathBuf,
pub data: PathBuf,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Input {
#[serde(rename = "pipe")]
pub pipe_path: Option<PathBuf>,
pub directories: Directories,
pub name: String,
pub options: serde_json::Value,
pub theme: Theme,
}
pub fn get_input() -> Option<Input> {
serde_json::from_reader(&mut std::io::stdin()).ok()
}