A command-line tool for crate registry backup/export https://shipyard.rs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

use chrono::prelude::*;
const README_TEMPLATE: &str = include_str!("../doc/README.tera.md");
const CLI_MENU: &str = include_str!("../doc/cli-menu.txt");
const JUST_COMMANDS: &str = include_str!("../doc/just-commands.txt");
const CONFIG_SAMPLE: &str = include_str!("../config.toml.sample");
fn get_commit_ref() -> Result<String, Box<dyn std::error::Error>> {
let output = std::process::Command::new("git")
.args(&["rev-parse", "HEAD"][..])
.output()?
.stdout;
let commit = std::str::from_utf8(&output[..8]).map(|x| x.to_string())?;
Ok(commit)
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut tera = tera::Tera::default();
tera.add_raw_template("README.md", README_TEMPLATE).unwrap();
let mut ctx = tera::Context::new();
ctx.insert("cli_menu", CLI_MENU);
ctx.insert("config_sample", CONFIG_SAMPLE);
ctx.insert("just_commands", JUST_COMMANDS);
ctx.insert("git_commit", &get_commit_ref()?);
ctx.insert("generation_time", &Utc::now().to_rfc2822());
let readme = tera.render("README.md", &ctx)?;
println!("{}", readme);
Ok(())
}