now using the bytes package
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -115,6 +115,7 @@ dependencies = [
|
|||||||
name = "docki"
|
name = "docki"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"zip-extract",
|
"zip-extract",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ license-file = "LICENSE.txt"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
bytes = "1.4.0"
|
||||||
regex = "1.7.1"
|
regex = "1.7.1"
|
||||||
reqwest = {version = "0.11.14", features = ["blocking"]}
|
reqwest = { version = "0.11.14", features = ["blocking"] }
|
||||||
zip-extract = "0.1.1"
|
zip-extract = "0.1.1"
|
||||||
|
|||||||
@@ -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 super::traits::Command;
|
||||||
|
use bytes::Bytes;
|
||||||
|
|
||||||
pub struct Setup;
|
pub struct Setup;
|
||||||
|
|
||||||
impl Command for Setup {
|
impl Command for Setup {
|
||||||
fn execute(&self, _args: &HashMap<String, String>) -> Result<(), String> {
|
fn execute(&self, _args: &HashMap<String, String>) -> Result<(), String> {
|
||||||
println!("setting up");
|
Self::setup();
|
||||||
return Ok(())
|
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_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 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");
|
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 {
|
let Ok(response) = reqwest::blocking::get(url) else {
|
||||||
return Err(());
|
return Err(());
|
||||||
};
|
};
|
||||||
@@ -36,7 +37,7 @@ impl Setup {
|
|||||||
return Err(());
|
return Err(());
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(&data)
|
return Ok(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user