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

Method format_default

atomic-cli/src/commands/log/command.rs:260–317  ·  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

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

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