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
42
43
use crate::{
args::Args,
config::user::UserConfig,
output::{print_step, APPLYING_EMOJI, CLEANING_EMOJI, FILLING_EMOJI},
};
use anyhow::Result;
use std::{fs::OpenOptions, io::Read, path::PathBuf};
pub mod args;
pub mod config;
pub mod git;
pub mod output;
pub mod providers;
pub mod steps;
pub fn start(args: Args, user_config_path: PathBuf) -> Result<()> {
let mut user_config_content = String::new();
let mut file = OpenOptions::new()
.create(true)
.read(true)
.write(true)
.open(user_config_path)?;
file.read_to_string(&mut user_config_content)?;
let user_config: UserConfig = toml::from_str(&user_config_content)?;
print_step(1, "> Cloning template repository...");
let repo_dir_path = crate::steps::clone::run(&args, &user_config)?;
print_step(2, &format!("{} Applying features...", APPLYING_EMOJI));
crate::steps::apply::run(&args, &user_config, &repo_dir_path)?;
print_step(3, &format!("{} Filling out templates...", FILLING_EMOJI));
crate::steps::populate::run(&args, &user_config, &repo_dir_path)?;
print_step(4, &format!("{} Cleaning up...", CLEANING_EMOJI));
crate::steps::cleanup::run(&repo_dir_path)?;
Ok(())
}