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

Method run

atomic-cli/src/commands/vault/list.rs:72–120  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

70
71impl Command for List {
72 fn run(&self) -> CliResult<()> {
73 let root = find_repository_root()?;
74 let repo = Repository::open(&root).map_err(CliError::Repository)?;
75
76 let type_filter = self.r#type.as_deref().and_then(VaultEntryType::parse);
77 let prefix = self.prefix.as_deref().unwrap_or("");
78
79 let entries = repo
80 .vault_list(prefix, type_filter)
81 .map_err(CliError::Repository)?;
82
83 if self.json {
84 let json: Vec<serde_json::Value> = entries
85 .iter()
86 .map(|e| {
87 serde_json::json!({
88 "path": e.path,
89 "type": e.entry_type,
90 "size": e.content_size,
91 "updated_at": e.updated_at,
92 })
93 })
94 .collect();
95 println!("{}", serde_json::to_string_pretty(&json).unwrap());
96 } else {
97 if entries.is_empty() {
98 println!("No vault entries found.");
99 return Ok(());
100 }
101
102 for entry in &entries {
103 println!(
104 " {:12} {:>8} {}",
105 entry.entry_type,
106 format_size(entry.content_size as u64),
107 entry.path,
108 );
109 }
110
111 let count_label = if entries.len() == 1 {
112 "entry"
113 } else {
114 "entries"
115 };
116 println!("\n{} {}", entries.len(), count_label);
117 }
118
119 Ok(())
120 }
121}

Callers

nothing calls this directly

Calls 5

find_repository_rootFunction · 0.85
vault_listMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected