feat: Progress bar and colored output
This commit is contained in:
23
src/main.rs
23
src/main.rs
@@ -16,3 +16,26 @@ fn main() {
|
|||||||
let url = matches.value_of("URL").unwrap();
|
let url = matches.value_of("URL").unwrap();
|
||||||
println!("{}", url);
|
println!("{}", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_progress_bar(quiet_mode: bool, msg: &str, length: Option<u64>) -> ProgressBar {
|
||||||
|
let bar = match quiet_mode {
|
||||||
|
true => ProgressBar::hidden(),
|
||||||
|
false => {
|
||||||
|
match length {
|
||||||
|
Some(len) => ProgressBar::new(len),
|
||||||
|
None => ProgressBar::new_spinner(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bar.set_message(msg);
|
||||||
|
match length.is_some() {
|
||||||
|
true => bar
|
||||||
|
.set_style(ProgressStyle::default_bar()
|
||||||
|
.template("{msg} {spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} eta: {eta}")
|
||||||
|
.progress_chars("=> ")),
|
||||||
|
false => bar.set_style(ProgressStyle::default_spinner()),
|
||||||
|
};
|
||||||
|
|
||||||
|
bar
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user