Improve cli argument validation
This commit is contained in:
parent
052c3a358a
commit
182442ba3b
23
src/main.rs
23
src/main.rs
@ -108,6 +108,10 @@ async fn main() -> ResBE<()> {
|
||||
}
|
||||
};
|
||||
|
||||
if numparal <= 0 {
|
||||
eprintln!("Invalid value for numdl: {}", numparal);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let boost = match arguments.value_of("boost") {
|
||||
Some(it) => it,
|
||||
@ -121,12 +125,24 @@ async fn main() -> ResBE<()> {
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
if boost <= 0 {
|
||||
eprintln!("Invalid value for boost: {}", boost);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let is_zippy = arguments.is_present("zippyshare");
|
||||
|
||||
if arguments.is_present("listfile") {
|
||||
|
||||
let listfile = arguments.value_of("listfile").unwrap();
|
||||
let s_listfile = arguments.value_of("listfile").unwrap();
|
||||
|
||||
let listfile = Path::new(s_listfile);
|
||||
|
||||
if !listfile.is_file() {
|
||||
eprintln!("Listfile '{}' does not exist!", s_listfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let ifile = std::fs::File::open(listfile)?;
|
||||
|
||||
@ -177,7 +193,10 @@ async fn download_multiple(urls: Vec<String>, outdir: &str, numparal: i32, boost
|
||||
let outdir = Path::new(outdir);
|
||||
|
||||
if !outdir.exists() {
|
||||
std::fs::create_dir_all(outdir)?;
|
||||
if let Err(_e) = std::fs::create_dir_all(outdir) {
|
||||
eprintln!("Error creating output directory '{}'", outdir.to_str().unwrap());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
let t_start = SystemTime::now();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user