-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
41 lines (30 loc) · 864 Bytes
/
build.rs
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
use std::{
fs::{self, File},
io::Write,
};
const UI_TO_USE: &[u8] = b"features = [\"term-ui\"]";
const LIB: &[u8] = include_bytes!("default-config/lib.rs_");
const TOML: &[u8] = include_bytes!("default-config/Cargo.toml_");
fn main() {
let Some(config_path) = dirs_next::config_dir() else {
return;
};
if !config_path.exists() {
return;
}
let dest = config_path.join("duat");
if dest.exists() {
return;
}
if fs::create_dir_all(&dest).is_err() {
return;
};
if fs::create_dir_all(dest.join("src")).is_err() {
return;
};
let mut src = File::create(dest.join("src/lib.rs")).unwrap();
src.write_all(LIB).unwrap();
let mut toml = File::create(dest.join("Cargo.toml")).unwrap();
toml.write_all(TOML).unwrap();
toml.write_all(UI_TO_USE).unwrap();
}