diff options
Diffstat (limited to '')
| -rw-r--r-- | src/ui.rs | 26 |
1 files changed, 25 insertions, 1 deletions
| @@ -150,7 +150,14 @@ pub fn tool_result(summary: &str, aborted: bool) { | |||
| 150 | let _ = std::io::stdout().flush(); | 150 | let _ = std::io::stdout().flush(); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | pub fn status(steps: usize, elapsed: Duration, outcome: &Outcome) { | 153 | #[derive(Debug, Default, Clone, Copy)] |
| 154 | pub struct Summary { | ||
| 155 | pub writes: usize, | ||
| 156 | pub commands: usize, | ||
| 157 | pub denied: usize, | ||
| 158 | } | ||
| 159 | |||
| 160 | pub fn status(steps: usize, elapsed: Duration, outcome: &Outcome, summary: &Summary) { | ||
| 154 | let mut parts = vec![ | 161 | let mut parts = vec![ |
| 155 | if steps == 1 { | 162 | if steps == 1 { |
| 156 | "1 step".to_string() | 163 | "1 step".to_string() |
| @@ -159,6 +166,23 @@ pub fn status(steps: usize, elapsed: Duration, outcome: &Outcome) { | |||
| 159 | }, | 166 | }, |
| 160 | format!("{:.1}s", elapsed.as_secs_f64()), | 167 | format!("{:.1}s", elapsed.as_secs_f64()), |
| 161 | ]; | 168 | ]; |
| 169 | if summary.writes > 0 { | ||
| 170 | parts.push(format!( | ||
| 171 | "{} write{}", | ||
| 172 | summary.writes, | ||
| 173 | if summary.writes == 1 { "" } else { "s" } | ||
| 174 | )); | ||
| 175 | } | ||
| 176 | if summary.commands > 0 { | ||
| 177 | parts.push(format!( | ||
| 178 | "{} command{}", | ||
| 179 | summary.commands, | ||
| 180 | if summary.commands == 1 { "" } else { "s" } | ||
| 181 | )); | ||
| 182 | } | ||
| 183 | if summary.denied > 0 { | ||
| 184 | parts.push(format!("{} denied", summary.denied)); | ||
| 185 | } | ||
| 162 | let (input, output) = outcome.tokens(); | 186 | let (input, output) = outcome.tokens(); |
| 163 | if let (Some(i), Some(o)) = (input, output) { | 187 | if let (Some(i), Some(o)) = (input, output) { |
| 164 | parts.push(format!("{i} in · {o} out")); | 188 | parts.push(format!("{i} in · {o} out")); |
