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

Method format_default

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

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

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