Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress bar #2309

Merged
merged 4 commits into from
May 11, 2019
Merged

Add progress bar #2309

merged 4 commits into from
May 11, 2019

Conversation

ry
Copy link
Member

@ry ry commented May 8, 2019

No description provided.

@ry ry requested a review from piscisaureus May 8, 2019 18:50
@bartlomieju
Copy link
Member

@ry a little suggestion from me: can progress bar be disabled after initial boot?

Once we support import() and Deno.deps("...") it's not desired to have additional Downloading/Compiling messages when any of them is used.

Ref comment

@ry
Copy link
Member Author

ry commented May 9, 2019

@bartlomieju I'm not sure about that... I would expect that if I import() something it would display some messages about what it's doing. That said, having a way to disable the progress bar would be useful as it would fix the TODO I have in main.rs.

@bartlomieju
Copy link
Member

@ry after second thoughts you're probably right. Re disabling of progress bar, maybe it could be handled by progress.unset_callback?

  pub fn unset_callback(&self)  {
    let mut s = self.0.lock().unwrap();
    assert!(s.callback.is_some());
    s.callback = None;
  }

@bartlomieju
Copy link
Member

@ry regarding a TODO from main.rs, you can resolve it like that:

progress.set_callback(|completed, total, msg| {
    eprint!("\x1B[K"); // Clear to end of line.
    eprint!("[{}/{}] {}\r", completed, total, msg);

    if completed == total {
      println!();
    }
  });
19:20 $ deno_dev run -r foo.ts
[58/58] Compiling file:///Users/biwanczuk/dev/deno/foo.ts
foobar!

@ry
Copy link
Member Author

ry commented May 9, 2019

@bartlomieju I tried that at first, but learned that completed == total doesn't necessarily mean it's done.

@bartlomieju
Copy link
Member

How about Inner.done_callback and Progress.done?

Taking into account two cases I presented before there would be 3 places to signal process bar that everything has been downloaded and compiled, and done_callback would only print new line. OTOH when I think of dynamic imports I can imagine a situation that progress bar showing dynamic import downloads would somehow overlap with user script output.

@ry
Copy link
Member Author

ry commented May 11, 2019

@bartlomieju As you suggested, I've added Progress::done()

Copy link
Member

@piscisaureus piscisaureus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good with a few remarks. I'll approve it like this, but please respond to comments.

cli/compiler.rs Show resolved Hide resolved
@@ -682,7 +688,10 @@ fn fetch_remote_source_async(
}
})
},
)
).then(move |r| {
drop(download_job);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. What is this drop() thing needed for?

cli/progress.rs Show resolved Hide resolved
@ry ry merged commit aba9523 into denoland:master May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants