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
//! rsw init
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use crate::core::RswInfo;
use crate::{
config, template,
utils::{path_exists, print},
};
pub struct Init;
impl Init {
pub fn new() -> std::io::Result<()> {
if !path_exists(Path::new(config::RSW_FILE)) {
File::create(config::RSW_FILE)?.write_all(template::RSW_TOML)?;
print(RswInfo::RswTomlOk);
} else {
print(RswInfo::RswTomExist);
}
Ok(())
}
}