pub fn init(path: &str, license: &str) -> errors::Result<()> {
    let config_path = format!("{}/{}", path, "ebox.json");
    let dir_exist = utils::dir_exist(path);
    let config_exist = utils::file_exist(&config_path);

    if !dir_exist {
        let _ = utils::dir_new(path)?;
    }

    if config_exist {
        return Err("folder already initiated".into());
    }

    let name = fs::canonicalize(PathBuf::from(path))
        .chain_err(|| "failed getting absolute path")?
        .file_name()
        .unwrap()
        .to_str()
        .unwrap()
        .to_string();

    let conf = Config {
        project: Project {
            name,
            license: String::from(license),
        },
        compiler: Compiler {
            optimize: false,
            runs: 0,
        },
        library: Vec::new(),
    };

    let _ = utils::file_new(&config_path, config_new(&conf)?.as_str());

    Ok(())
}
// actions for initiating new ebox project.
actions for initiating new ebox project.
actions for initiating new ebox project .
pub fn init(path: &str, license: &str) -> errors::Result<()> {
    let config_path = format!("{}/{}", path, "ebox.json");
    let dir_exist = utils::dir_exist(path);
    let config_exist = utils::file_exist(&config_path);
    if !dir_exist {
        let _ = utils::dir_new(path)?;
    }
    if config_exist {
        return Err("folder already initiated".into());
    }
    let name = fs::canonicalize(PathBuf::from(path))
        .chain_err(|| "failed getting absolute path")?
        .file_name()
        .unwrap()
        .to_str()
        .unwrap()
        .to_string();
    let conf = Config {
        project: Project {
            name,
            license: String::from(license),
        },
        compiler: Compiler {
            optimize: false,
            runs: 0,
        },
        library: Vec::new(),
    };
    let _ = utils::file_new(&config_path, config_new(&conf)?.as_str());
    Ok(())
}
pub fn init ( path : & str , license : & str ) -> errors :: Result < ( ) > { let config_path = format ! ( " " path " " ) ; let dir_exist = utils :: dir_exist ( path ) ; let config_exist = utils :: file_exist ( & config_path ) ; if ! dir_exist { let _ = utils :: dir_new ( path ) ? ; } if config_exist { return Err ( " " . into ( ) ) ; } let name = fs :: canonicalize ( PathBuf :: from ( path ) ) . chain_err ( | | " " ) ? . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ; let conf = Config { project : Project { name , license : String :: from ( license ) , } , compiler : Compiler { optimize : false , runs : 0 , } , library : Vec :: new ( ) , } ; let _ = utils :: file_new ( & config_path , config_new ( & conf ) ? . as_str ( ) ) ; Ok ( ( ) ) }
actions for initiating new ebox project.
actions for initiating new ebox project .
path
&str
license
&str