Made the commands easier

This commit is contained in:
Skye Bleed 2019-09-03 18:17:02 -05:00
parent 8deb3e4953
commit d5a373901e
2 changed files with 14 additions and 4 deletions

BIN
pack

Binary file not shown.

View file

@ -1,7 +1,9 @@
use std::fs::File; use std::fs::File;
use std::path::Path; use std::path::Path;
use std::io::Read; use std::io::Read;
use std::result::Result;
use reqwest::IntoUrl;
use reqwest::Client; use reqwest::Client;
use reqwest::header::ETAG; use reqwest::header::ETAG;
@ -26,12 +28,20 @@ fn main() -> Result<(), std::io::Error> {
std::process::exit(1); std::process::exit(1);
} }
print!("Making request...");
let mut resp = client.get(vec[0])
.send().expect("Failed to make request");
let full_path: Vec<&str> = vec[0].split("/").collect(); let full_path: Vec<&str> = vec[0].split("/").collect();
let pkgname = full_path[full_path.len() - 1]; let pkgname = full_path[full_path.len() - 1];
let repo = match vec[1] {
"arch" => "http://mirrors.advancedhosters.com/archlinux/core/os/x86_64/",
_ => {
println!("Repo {} is not supported...", vec[1]);
std::process::exit(0);
},
};
print!("Making request...");
let url = reqwest::Url::parse(&(repo.to_string() + pkgname)).expect("Failed to parse URL");
let mut resp = client.get(url)
.send().expect("Failed to make request");
if resp.status().is_success() { if resp.status().is_success() {
println!("OK"); println!("OK");