add install for reveal. docs in progrees

This commit is contained in:
2023-02-05 22:06:16 +01:00
parent f74638e8fc
commit df1255d479

View File

@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, env, fs::File, io::Write, fmt::format};
use super::traits::Command;
@@ -14,3 +14,40 @@ impl Command for Setup {
return Self {}
}
}
impl Setup {
fn setup() {
let os = env::consts::OS;
let reveal_bin_url = format!("https://github.com/asciidoctor/asciidoctor-reveal.js/releases/download/v5.0.0-rc.1/asciidoctor-revealjs-{os}");
let reveal_bin = Self::donwload(&reveal_bin_url).expect("could not download asciidoctor binary");
let mut reveal_file = File::create("/usr/local/bin/asciidoctor").expect("could not save asciidoctor binary");
reveal_file.write_all(reveal_bin);
}
fn donwload(url: &str) -> Result<&[u8], ()> {
let Ok(response) = reqwest::blocking::get(url) else {
return Err(());
};
let Ok(data) = response.bytes() else {
return Err(());
};
return Ok(&data)
}
}
#[cfg(test)]
mod test {
use std::env;
#[test]
fn download() {
println!("{}", env::consts::OS);
assert!(false)
}
}