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
use crate::lib::{
config::autoconfig::{get_home_files, get_root_files},
fsutil::paths::get_root,
structs::config::KelpDotConfig,
};
use kelpdot_macros::*;
use std::path::Path;
pub fn init() -> anyhow::Result<()> {
let root = get_root()?;
debug_print!("Root: {}", root);
if Path::new(&format!("{}/kelp.yaml", root)).exists() {
red_print!("{}/kelp.yaml already exists!", root);
std::process::exit(1);
}
let rootfiles = get_root_files()?;
let homefiles = get_home_files()?;
let cfg = KelpDotConfig {
homefiles: Some(homefiles),
rootfiles: Some(rootfiles),
postrun: Some(vec![]),
prerun: Some(vec![]),
postsave: Some(vec![]),
};
let conf_path = format!("{}/kelp.yaml", root);
magenta_print!("[INFO] Config file {} created!", conf_path);
std::fs::write(conf_path, serde_yaml::to_string(&cfg)?)?;
Ok(())
}