summaryrefslogtreecommitdiffstats
path: root/src/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 3148df9..2fdda1a 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -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
153pub fn status(steps: usize, elapsed: Duration, outcome: &Outcome) { 153#[derive(Debug, Default, Clone, Copy)]
154pub struct Summary {
155 pub writes: usize,
156 pub commands: usize,
157 pub denied: usize,
158}
159
160pub 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"));