cli: include total downloaded size in progress output

With this change, the output looks like this:

```
  3% 165.9 Mi at  13.4 MiB/s [█▋                                                   ]
```

Closes #1483.
This commit is contained in:
Martin von Zweigbergk 2023-04-05 05:26:47 -07:00 committed by Martin von Zweigbergk
parent 308a5b9eae
commit ac27cdea69
2 changed files with 7 additions and 1 deletions

View File

@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `jj squash` AKA `jj amend` now accepts a `--message` option to set the
description of the squashed commit on the command-line.
* The progress display on `jj git clone/fetch` now includes the downloaded size.
### Fixed bugs
* Modify/delete conflicts now include context lines

View File

@ -57,9 +57,13 @@ impl Progress {
write!(self.buffer, "\r{}", Clear(ClearType::CurrentLine)).unwrap();
let control_chars = self.buffer.len();
write!(self.buffer, "{: >3.0}% ", 100.0 * progress.overall).unwrap();
if let Some(total) = progress.bytes_downloaded {
let (scaled, prefix) = binary_prefix(total as f32);
write!(self.buffer, "{scaled: >5.1} {prefix}B ").unwrap();
}
if let Some(estimate) = rate {
let (scaled, prefix) = binary_prefix(estimate);
write!(self.buffer, " at {scaled: >5.1} {prefix}B/s ").unwrap();
write!(self.buffer, "at {scaled: >5.1} {prefix}B/s ").unwrap();
}
let bar_width = ui