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

Function render_rows

atomic-cli/src/commands/vault/list.rs:82–112  ·  view source on GitHub ↗

The shared render — the exact local body's table and JSON shapes.

(rows: &[EntryRow], json: bool)

Source from the content-addressed store, hash-verified

80
81/// The shared render — the exact local body's table and JSON shapes.
82pub(crate) fn render_rows(rows: &[EntryRow], json: bool) {
83 if json {
84 let json: Vec<serde_json::Value> = rows
85 .iter()
86 .map(|e| {
87 serde_json::json!({
88 "path": e.path,
89 "type": e.entry_type,
90 "size": e.size,
91 "updated_at": e.updated_at,
92 })
93 })
94 .collect();
95 println!("{}", serde_json::to_string_pretty(&json).unwrap());
96 return;
97 }
98 if rows.is_empty() {
99 println!("No vault entries found.");
100 return;
101 }
102 for entry in rows {
103 println!(
104 " {:12} {:>8} {}",
105 entry.entry_type,
106 format_size(entry.size),
107 entry.path,
108 );
109 }
110 let count_label = if rows.len() == 1 { "entry" } else { "entries" };
111 println!("\n{} {}", rows.len(), count_label);
112}
113
114impl Command for List {
115 fn run(&self) -> CliResult<()> {

Callers 2

vault_listFunction · 0.85
runMethod · 0.85

Calls 4

collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected