MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_default

Method format_default

atomic-cli/src/commands/log/command.rs:262–319  ·  view source on GitHub ↗

Format entries for default output. # Arguments `entries` - History entries to format `hash_length` - Number of hash characters to display # Returns Formatted output string.

(&self, entries: &[HistoryEntry], hash_length: usize)

Source from the content-addressed store, hash-verified

260 ///
261 /// Formatted output string.
262 pub(crate) fn format_default(&self, entries: &[HistoryEntry], hash_length: usize) -> String {
263 let mut output = String::new();
264
265 for (i, entry) in entries.iter().enumerate() {
266 // Add separator between entries
267 if i > 0 {
268 output.push('\n');
269 }
270
271 // Change header line with hash between === markers for easy copy-paste
272 let hash_str = format_hash_with_length(&entry.hash, hash_length);
273 let tagged_marker = if entry.is_tagged { " (tag)" } else { "" };
274 let seq_str = format!("#{}", entry.sequence);
275 output.push_str(&format!(
276 "{} === {} ==={}\n",
277 hint(&seq_str),
278 style_hash(&hash_str),
279 hint(tagged_marker)
280 ));
281
282 // Authors
283 if let Some(authors) = entry.authors() {
284 for author in authors {
285 let author_line = if let Some(ref email) = author.email {
286 format!("{} <{}>", author.name, email)
287 } else {
288 author.name.clone()
289 };
290 output.push_str(&format!("Author: {}\n", style_author(&author_line)));
291 }
292 }
293
294 // Timestamp
295 if let Some(ts) = entry.timestamp() {
296 let formatted_time = format_timestamp(&ts);
297 output.push_str(&format!("Date: {}\n", style_timestamp(&formatted_time)));
298 }
299
300 // Message
301 output.push('\n');
302 if let Some(message) = entry.message() {
303 // Indent message lines
304 for line in message.lines() {
305 output.push_str(&format!(" {}\n", line));
306 }
307 }
308
309 // Description
310 if let Some(description) = entry.description() {
311 output.push('\n');
312 for line in description.lines() {
313 output.push_str(&format!(" {}\n", line));
314 }
315 }
316 }
317
318 output
319 }

Calls 10

format_hash_with_lengthFunction · 0.85
format_timestampFunction · 0.85
iterMethod · 0.45
pushMethod · 0.45
authorsMethod · 0.45
cloneMethod · 0.45
timestampMethod · 0.45
messageMethod · 0.45
linesMethod · 0.45
descriptionMethod · 0.45