pub fn format_seconds(ms: u64) -> String {
let mut seconds = format!("{:.1}", ms as f64 / 1000.0);
if seconds.ends_with(".0") {
seconds.truncate(seconds.len() - 2);
}
format!("{seconds}s")
}
pub fn format_wait_limit(ms: u64) -> String {
match ms {
60_000 => "1 minute".to_string(),
ms if ms > 0 && ms % 60_000 == 0 => format!("{} minutes", ms / 60_000),
ms => format_seconds(ms),
}
}
pub fn append_trailing_line(text: &mut String, line: &str) {
if !text.is_empty() {
text.push_str(if text.ends_with('\n') { "\n" } else { "\n\n" });
}
text.push_str(line);
}
#[cfg(unix)]
pub fn append_db_schema_hint(text: &mut String, hint: &str) {
append_trailing_line(text, hint);
}