Format duration as human-readable string
(&self)
| 11 | impl CommandResult { |
| 12 | /// Format duration as human-readable string |
| 13 | pub fn format_duration(&self) -> String { |
| 14 | let secs = self.duration.as_secs(); |
| 15 | |
| 16 | if secs < 60 { |
| 17 | format!("{}s", secs) |
| 18 | } else if secs < 3600 { |
| 19 | let mins = secs / 60; |
| 20 | let remaining_secs = secs % 60; |
| 21 | format!("{}m {}s", mins, remaining_secs) |
| 22 | } else { |
| 23 | let hours = secs / 3600; |
| 24 | let mins = (secs % 3600) / 60; |
| 25 | format!("{}h {}m", hours, mins) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /// Run a command with inherited stdio and return the result |
no outgoing calls
no test coverage detected