Files
docki/src/app/commands/install_reveal.rs

27 lines
941 B
Rust

use std::{fs::File, io::Write};
use crate::app::fs_util;
const ASCIIDOC_REVEAL_VERSION: &str= "v4.1.0-rc.5";
pub async fn install_reveal() -> () {
let result = reqwest::blocking::get(url())
.expect("Could not download reveal. Make sure you are connected to the internet");
let binary = result.bytes().expect("could not get binary");
let home_path = home::home_dir().expect("could not find home dir");
let save_path = format!("{}/.docki/asciidoctor-revealjs", home_path.display());
let save_dir = format!("{}/.docki", home_path.display());
fs_util::create_dir_recursive(save_dir.as_str());
let mut file = File::create(save_path).expect("could not save binary");
file.write_all(&binary).expect("could not save binary");
}
fn url() -> String {
return format!("https://github.com/asciidoctor/asciidoctor-reveal.js/releases/download/{}/asciidoctor-revealjs-linux", ASCIIDOC_REVEAL_VERSION);
}