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

Function render_line

atomic-cli/src/commands/view/list.rs:366–412  ·  view source on GitHub ↗

Render one view line for the default (metadata) mode.

(entry: &ViewEntry, depth: usize, width: usize)

Source from the content-addressed store, hash-verified

364
365/// Render one view line for the default (metadata) mode.
366pub(crate) fn render_line(entry: &ViewEntry, depth: usize, width: usize) -> String {
367 let prefix = tree_prefix(entry, depth);
368 let name = style_view(&entry.name);
369
370 if !entry.has_info {
371 return format!("{}{}", prefix, name);
372 }
373
374 let kind_tag = if entry.kind == "draft" {
375 "[draft]"
376 } else {
377 "[shared]"
378 };
379 // Show own changes for views with a parent; show total for root views.
380 let change_display = if entry.parent.is_some() {
381 if entry.own_change_count == 1 {
382 format!(
383 "({} change, {} inherited)",
384 entry.own_change_count, entry.inherited_change_count
385 )
386 } else {
387 format!(
388 "({} changes, {} inherited)",
389 entry.own_change_count, entry.inherited_change_count
390 )
391 }
392 } else if entry.change_count == 1 {
393 "(1 change)".to_string()
394 } else {
395 format!("({} changes)", entry.change_count)
396 };
397 let parent_info = match &entry.parent {
398 Some(p) => format!(" parent: {}", style_view(p)),
399 None => String::new(),
400 };
401
402 format!(
403 "{}{:<width$} {:<10} {} state: {}{}",
404 prefix,
405 name,
406 kind_tag,
407 change_display,
408 entry.state_short,
409 parent_info,
410 width = width
411 )
412}
413
414/// Render one view line for `--short` mode (names only).
415pub(crate) fn render_short_line(entry: &ViewEntry, depth: usize) -> String {

Callers 4

view_listFunction · 0.85
runMethod · 0.85
test_root_line_formatFunction · 0.85

Calls 1

tree_prefixFunction · 0.85

Tested by 2

test_root_line_formatFunction · 0.68