rsw/core/
init.rs

1//! rsw init
2
3use std::fs::File;
4use std::io::prelude::*;
5use std::path::Path;
6
7use crate::core::RswInfo;
8use crate::{
9    config, template,
10    utils::{path_exists, print},
11};
12
13pub struct Init;
14
15impl Init {
16    pub fn new() -> std::io::Result<()> {
17        if !path_exists(Path::new(config::RSW_FILE)) {
18            File::create(config::RSW_FILE)?.write_all(template::RSW_TOML)?;
19            print(RswInfo::RswTomlOk);
20        } else {
21            print(RswInfo::RswTomExist);
22        }
23
24        Ok(())
25    }
26}