now using the bytes package
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use std::{collections::HashMap, env, fs::File, io::Write, fmt::format};
|
||||
use std::{collections::HashMap, env, fs::File, io::Write};
|
||||
|
||||
use super::traits::Command;
|
||||
use bytes::Bytes;
|
||||
|
||||
pub struct Setup;
|
||||
|
||||
impl Command for Setup {
|
||||
fn execute(&self, _args: &HashMap<String, String>) -> Result<(), String> {
|
||||
println!("setting up");
|
||||
Self::setup();
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -24,10 +25,10 @@ impl Setup {
|
||||
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);
|
||||
reveal_file.write_all(&reveal_bin).expect("could not save asciidoctor binary");
|
||||
}
|
||||
|
||||
fn donwload(url: &str) -> Result<&[u8], ()> {
|
||||
fn donwload(url: &str) -> Result<Bytes, ()> {
|
||||
let Ok(response) = reqwest::blocking::get(url) else {
|
||||
return Err(());
|
||||
};
|
||||
@@ -36,7 +37,7 @@ impl Setup {
|
||||
return Err(());
|
||||
};
|
||||
|
||||
return Ok(&data)
|
||||
return Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user