feat: vanilla server downloading + lots of ux improvements
This commit is contained in:
parent
505bfbbb5d
commit
0a12b87a2a
6 changed files with 241 additions and 22 deletions
23
src/utils.rs
Normal file
23
src/utils.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use std::{error::Error, future::Future};
|
||||
use indicatif::ProgressBar;
|
||||
|
||||
pub async fn with_spinner<F, Fut, T>(
|
||||
start_msg: &str,
|
||||
finish_msg: &str,
|
||||
f: F,
|
||||
) -> Result<T, Box<dyn Error>>
|
||||
where
|
||||
F: FnOnce() -> Fut,
|
||||
Fut: Future<Output = Result<T, Box<dyn Error>>>,
|
||||
{
|
||||
let pb = ProgressBar::new_spinner();
|
||||
pb.set_message(start_msg.to_string());
|
||||
pb.enable_steady_tick(std::time::Duration::from_millis(100));
|
||||
|
||||
let result = f().await;
|
||||
|
||||
pb.finish_and_clear();
|
||||
println!("{} {}", dialoguer::console::style("✔").green(), finish_msg);
|
||||
|
||||
result
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue