Format a group of files with a verb prefix. - 1-3 files: `"Add src/main.rs, Cargo.toml, lib.rs"` - 4+ files: `"Add src/main.rs, Cargo.toml (+2 more)"`
(verb: &str, files: &[String])
| 338 | /// - 1-3 files: `"Add src/main.rs, Cargo.toml, lib.rs"` |
| 339 | /// - 4+ files: `"Add src/main.rs, Cargo.toml (+2 more)"` |
| 340 | pub(crate) fn format_file_group(verb: &str, files: &[String]) -> String { |
| 341 | match files.len() { |
| 342 | 0 => String::new(), |
| 343 | 1 => format!("{} {}", verb, files[0]), |
| 344 | 2 => format!("{} {}, {}", verb, files[0], files[1]), |
| 345 | 3 => format!("{} {}, {}, {}", verb, files[0], files[1], files[2]), |
| 346 | n => format!("{} {}, {} (+{} more)", verb, files[0], files[1], n - 2), |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /// Truncate a prompt to the given maximum length, adding "..." if needed. |
| 351 | pub(crate) fn truncate_prompt(prompt: &str, max_len: usize) -> String { |
no test coverage detected