makereadme/
lib.rs

1use clap::Parser;
2use handlebars::Handlebars;
3use rust_embed::RustEmbed;
4
5mod repodata;
6
7const BLUEPRINT_FILE: &str = "blueprint.md";
8const OUTPUT_FILE: &str = "README.md";
9
10// embed the blueprint files
11#[derive(RustEmbed)]
12#[folder = "assets/"]
13struct Assets;
14
15#[derive(Parser)]
16#[command(author, version, about, long_about = None)]
17struct Cli;
18
19pub fn run() {
20    // Just to provide --version and --help
21    let _cli = Cli::parse();
22
23    let repo_info = repodata::RepoData::ask_questions();
24
25    let mut hbs = Handlebars::new();
26
27    hbs.register_embed_templates::<Assets>().expect(&format!(
28        "Failed to register {} to templates.",
29        BLUEPRINT_FILE
30    ));
31
32    let mut output_file =
33        std::fs::File::create(OUTPUT_FILE).expect(&format!("Failed to create {}", OUTPUT_FILE));
34
35    hbs.render_to_write(BLUEPRINT_FILE, &repo_info, &mut output_file)
36        .unwrap();
37}