summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-05-30 11:07:58 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-06-25 06:32:28 -0700
commit3a4d88475b40a17f2ce17b775a3f07c78be83d79 (patch)
tree2780e2c7ea86c0a7e039cfc3e478bd82131a467e /cli/main.rs
parent89216c7baaab8ade3daf9103572647addeb404f3 (diff)
Port code from Cargo and use for progress
A lot of its functionality is unused still, but the goal it to slowly migrate logging functionality to it. There is also a useful progress bar which can be ported over later - it depends on this module. https://github.com/rust-lang/cargo/blob/4c1fa54d10f58d69ac9ff55be68e1b1c25ecb816/src/cargo/util/progress.rs
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 05748f5ab..8121e5f7c 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -35,6 +35,7 @@ mod progress;
mod repl;
pub mod resolve_addr;
pub mod resources;
+mod shell;
mod signal;
pub mod source_maps;
mod startup_data;
@@ -158,17 +159,15 @@ fn create_worker_and_state(
flags: DenoFlags,
argv: Vec<String>,
) -> (Worker, ThreadSafeState) {
+ use crate::shell::Shell;
+ use std::sync::Arc;
+ use std::sync::Mutex;
+ let shell = Arc::new(Mutex::new(Shell::new()));
let progress = Progress::new();
- progress.set_callback(|done, completed, total, msg| {
- if !done {
- eprint!("\r[{}/{}] {}", completed, total, msg);
- eprint!("\x1B[K"); // Clear to end of line.
- return;
- }
-
- // print empty line only if progress bar was used
- if done && total > 0 {
- eprintln!();
+ progress.set_callback(move |_done, _completed, _total, status, msg| {
+ if !status.is_empty() {
+ let mut s = shell.lock().unwrap();
+ s.status(status, msg).expect("shell problem");
}
});
let state = ThreadSafeState::new(flags, argv, ops::op_selector_std, progress);