refactored the project using the clap crate

This commit is contained in:
2023-03-08 21:35:15 +01:00
parent e469576d2c
commit 4b789e60c9
10 changed files with 92 additions and 233 deletions

View File

@@ -0,0 +1,26 @@
use std::{fs::File, io::Write};
use crate::app::fs_util;
const ASCIIDOC_REVEAL_VERSION: &str= "v4.1.0-rc.5";
pub 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);
}