diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-05-11 10:23:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-11 10:23:19 -0400 |
commit | aba952397ae668714add770c5b6fa6edf1cf3eb5 (patch) | |
tree | a1d2f0bd9758cdd5b196e3ed8efc12c657795aab /cli/main.rs | |
parent | 2c6b93e0a0c7927dc4dd66c1f681a78a6d79b8f1 (diff) |
Add progress bar (#2309)
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/main.rs b/cli/main.rs index a864c2db3..2423c4936 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -27,6 +27,7 @@ pub mod msg; pub mod msg_util; pub mod ops; pub mod permissions; +mod progress; mod repl; pub mod resolve_addr; pub mod resources; @@ -39,6 +40,7 @@ pub mod version; pub mod worker; use crate::errors::RustOrJsError; +use crate::progress::Progress; use crate::state::ThreadSafeState; use crate::worker::root_specifier_to_url; use crate::worker::Worker; @@ -134,7 +136,16 @@ fn create_worker_and_state( flags: DenoFlags, argv: Vec<String>, ) -> (Worker, ThreadSafeState) { - let state = ThreadSafeState::new(flags, argv, ops::op_selector_std); + let progress = Progress::new(); + progress.set_callback(|done, completed, total, msg| { + if done { + eprintln!(""); + } else { + eprint!("\r[{}/{}] {}", completed, total, msg); + eprint!("\x1B[K"); // Clear to end of line. + } + }); + let state = ThreadSafeState::new(flags, argv, ops::op_selector_std, progress); let worker = Worker::new( "main".to_string(), startup_data::deno_isolate_init(), |