diff options
Diffstat (limited to '')
| -rw-r--r-- | src/ui.rs | 24 |
1 files changed, 17 insertions, 7 deletions
| @@ -109,7 +109,7 @@ impl<W: Write> Sink for Renderer<W> { | |||
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) { | 112 | pub fn tool_line(step: usize, name: &str, args: &serde_json::Value, include_detail: bool) { |
| 113 | let detail = match name { | 113 | let detail = match name { |
| 114 | "bash" => args | 114 | "bash" => args |
| 115 | .get("cmd") | 115 | .get("cmd") |
| @@ -132,11 +132,12 @@ pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) { | |||
| 132 | .unwrap_or("") | 132 | .unwrap_or("") |
| 133 | .to_string(), | 133 | .to_string(), |
| 134 | }; | 134 | }; |
| 135 | println!( | 135 | let head = paint("1;36", &format!("● [{step}] {name}")); |
| 136 | "{} {}", | 136 | if include_detail && !detail.is_empty() { |
| 137 | paint("1;36", &format!("● [{step}] {name}")), | 137 | println!("{head} {detail}"); |
| 138 | detail | 138 | } else { |
| 139 | ); | 139 | println!("{head}"); |
| 140 | } | ||
| 140 | let _ = std::io::stdout().flush(); | 141 | let _ = std::io::stdout().flush(); |
| 141 | } | 142 | } |
| 142 | 143 | ||
| @@ -264,7 +265,9 @@ impl Approver { | |||
| 264 | return true; | 265 | return true; |
| 265 | } | 266 | } |
| 266 | println!("{preview}"); | 267 | println!("{preview}"); |
| 267 | match self.ask(&format!("apply this change to {path}?"), true) { | 268 | // The path is already on the tool line above. |
| 269 | let _ = path; | ||
| 270 | match self.ask("apply this change?", true) { | ||
| 268 | Answer::Yes => true, | 271 | Answer::Yes => true, |
| 269 | Answer::Always => { | 272 | Answer::Always => { |
| 270 | self.edits_allowed = true; | 273 | self.edits_allowed = true; |
| @@ -274,6 +277,13 @@ impl Approver { | |||
| 274 | } | 277 | } |
| 275 | } | 278 | } |
| 276 | 279 | ||
| 280 | /// True when the next bash call will actually be shown to a human, which is | ||
| 281 | /// the only case where the command appears in the prompt rather than the | ||
| 282 | /// tool line. | ||
| 283 | pub fn will_prompt_bash(&self) -> bool { | ||
| 284 | !self.yolo && self.interactive | ||
| 285 | } | ||
| 286 | |||
| 277 | /// Every call, no memory: the point is seeing the command. | 287 | /// Every call, no memory: the point is seeing the command. |
| 278 | pub fn allow_bash(&mut self, cmd: &str) -> bool { | 288 | pub fn allow_bash(&mut self, cmd: &str) -> bool { |
| 279 | if self.yolo { | 289 | if self.yolo { |
