diff options
Diffstat (limited to 'crates/typst-cli')
| -rw-r--r-- | crates/typst-cli/src/download.rs | 28 | ||||
| -rw-r--r-- | crates/typst-cli/src/watch.rs | 16 |
2 files changed, 22 insertions, 22 deletions
diff --git a/crates/typst-cli/src/download.rs b/crates/typst-cli/src/download.rs index 3e3d8294..ca1e539d 100644 --- a/crates/typst-cli/src/download.rs +++ b/crates/typst-cli/src/download.rs @@ -5,7 +5,7 @@ use std::time::{Duration, Instant}; use codespan_reporting::term; use codespan_reporting::term::termcolor::WriteColor; -use typst::utils::format; +use typst::utils::format_duration; use typst_kit::download::{DownloadState, Downloader, Progress}; use crate::terminal::{self, TermOut}; @@ -62,9 +62,7 @@ pub fn display_download_progress( let total_downloaded = as_bytes_unit(state.total_downloaded); let speed_h = as_throughput_unit(speed); - let elapsed = format::time_starting_with_seconds( - &Instant::now().saturating_duration_since(state.start_time), - ); + let elapsed = Instant::now().saturating_duration_since(state.start_time); match state.content_len { Some(content_len) => { @@ -72,20 +70,26 @@ pub fn display_download_progress( let remaining = content_len - state.total_downloaded; let download_size = as_bytes_unit(content_len); - let eta = - format::time_starting_with_seconds(&Duration::from_secs(if speed == 0 { - 0 - } else { - (remaining / speed) as u64 - })); + let eta = Duration::from_secs(if speed == 0 { + 0 + } else { + (remaining / speed) as u64 + }); + writeln!( out, - "{total_downloaded} / {download_size} ({percent:3.0} %) {speed_h} in {elapsed} ETA: {eta}", + "{total_downloaded} / {download_size} ({percent:3.0} %) \ + {speed_h} in {elapsed} ETA: {eta}", + elapsed = format_duration(elapsed), + eta = format_duration(eta), )?; } None => writeln!( out, - "Total downloaded: {total_downloaded} Speed: {speed_h} Elapsed: {elapsed}", + "Total downloaded: {total_downloaded} \ + Speed: {speed_h} \ + Elapsed: {elapsed}", + elapsed = format_duration(elapsed), )?, }; Ok(()) diff --git a/crates/typst-cli/src/watch.rs b/crates/typst-cli/src/watch.rs index eb437ffd..f3ca329b 100644 --- a/crates/typst-cli/src/watch.rs +++ b/crates/typst-cli/src/watch.rs @@ -11,7 +11,7 @@ use ecow::eco_format; use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher as _}; use same_file::is_same_file; use typst::diag::{bail, StrResult}; -use typst::utils::format; +use typst::utils::format_duration; use crate::args::{CompileCommand, Input, Output}; use crate::compile::compile_once; @@ -296,18 +296,14 @@ impl Status { } fn message(&self) -> String { - match self { + match *self { Self::Compiling => "compiling ...".into(), Self::Success(duration) => { - format!( - "compiled successfully in {}", - format::time_starting_with_milliseconds(duration, 2) - ) + format!("compiled successfully in {}", format_duration(duration)) + } + Self::PartialSuccess(duration) => { + format!("compiled with warnings in {}", format_duration(duration)) } - Self::PartialSuccess(duration) => format!( - "compiled with warnings in {}", - format::time_starting_with_milliseconds(duration, 2) - ), Self::Error => "compiled with errors".into(), } } |
