Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ksk001100 committed Jan 20, 2020
1 parent acc9861 commit 1e7205e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 17 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ruget"
version = "0.1.3"
version = "0.2.0"
authors = ["ksk001100 <[email protected]>"]
edition = "2018"
repository = "https://github.com/ksk001100/ruget"
Expand All @@ -13,3 +13,4 @@ description = "Alternative to wget written in Rust"
reqwest = "0.9"
rayon = "1.1"
num_cpus = "1.0"
seahorse = "0.3.1"
10 changes: 4 additions & 6 deletions src/lib/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ pub fn is_accept_ranges(url: &str) -> bool {
let client = Client::new();
let res = client.head(url).send().expect("head failed...");
match res.headers().get(ACCEPT_RANGES) {
Some(res) => {
match res.to_str().unwrap() {
"none" => false,
_ => true,
}
Some(res) => match res.to_str().unwrap() {
"none" => false,
_ => true,
},
None => false
None => false,
}
}

Expand Down
47 changes: 38 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,53 @@ mod lib;
use std::{env, process::exit};

use rayon::ThreadPoolBuilder;
use seahorse::{Action, SingleApp, color};

use lib::download_manager::DownloadManager;

const DISPLAY_NAME: &'static str = "
___
,--.'|_
__ ,-. ,--, | | :,'
,' ,'/ /| ,'_ /| ,----._,. : : ' :
' | |' | .--. | | : / / ' / ,---. .;__,' /
| | ,','_ /| : . || : | / \\ | | |
' : / | ' | | . .| | .\\ . / / |:__,'| :
| | ' | | ' | | |. ; '; |. ' / | ' : |__
; : | : | : ; ; |' . . |' ; /| | | '.'|
| , ; ' : `--' \\`---`-'| |' | / | ; : ;
---' : , .-./.'__/\\_: || : | | , /
`--`----' | : : \\ \\ / ---`-'
\\ \\ / `----'
`--`-'
";

fn main() {
ThreadPoolBuilder::new()
.num_threads(num_cpus::get() * 2)
.build_global()
.unwrap();

let args: Vec<String> = env::args().collect();
let url = match args.len() {
2 => &args[1],
_ => {
eprintln!("Please specify a URL...");
exit(1);
}
let action: Action = |v: Vec<String>| {
let url = match v.len() {
1 => &v[0],
_ => {
eprintln!("Please specify a URL...");
exit(1);
}
};

let download_manager = DownloadManager::new(url.to_owned());
download_manager.downloader.download();
};

let download_manager = DownloadManager::new(url.to_owned());
download_manager.downloader.download();
}
let app = SingleApp::new()
.name("ruget")
.display_name(color::red(DISPLAY_NAME))
.usage("ruget [url]")
.version(env!("CARGO_PKG_VERSION"))
.action(action);

app.run(args);
}

0 comments on commit 1e7205e

Please sign in to comment.