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

Display download's elapsed time as seconds #236

Merged
merged 2 commits into from
Mar 3, 2022
Merged

Conversation

ducaale
Copy link
Owner

@ducaale ducaale commented Mar 3, 2022

Since we're planning to support HTTPie's --meta flag for displaying the response's elapsed time, I thought we should simplify how we display elapsed time everywhere.

Before:

Downloading 10.00MiB to "<stdout>"
Done. 10.00MiB in 4s 810ms 951us 800ns (2.08MiB/s)

After:

Downloading 10.00MiB to "<stdout>"
Done. 10.00MiB in 10.892807s (940.07KiB/s)

src/download.rs Outdated
HumanBytes(downloaded_length),
humantime::format_duration(time_taken),
time_taken.as_secs_f32(),
Copy link
Owner Author

Choose a reason for hiding this comment

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

I could have used as_secs_f64() here, but the resulting output would be too lengthy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To give the output the right length you can format it with {:.5} instead of {}. HTTPie does the same.

@ducaale ducaale merged commit 4da3ccb into develop Mar 3, 2022
@ducaale ducaale deleted the elapsed-time-formatting branch March 3, 2022 22:53
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.

None yet

2 participants