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

Method run

atomic-cli/src/commands/vault/context.rs:172–218  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

170
171impl Command for Context {
172 fn run(&self) -> CliResult<()> {
173 let as_json = self.json || self.format.eq_ignore_ascii_case("json");
174 if !as_json && !self.format.eq_ignore_ascii_case("md") {
175 return Err(CliError::InvalidArgument {
176 message: format!("Unknown format: {} (expected md or json)", self.format),
177 });
178 }
179
180 if !(1..=MAX_LIMIT).contains(&self.limit) {
181 return Err(CliError::InvalidArgument {
182 message: format!("--limit must be between 1 and {MAX_LIMIT}"),
183 });
184 }
185
186 let root = find_repository_root()?;
187 let repo =
188 crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?;
189
190 let limit = self.limit;
191 let candidates = self.gather_candidates(&repo, limit)?;
192 let items = resolve_and_rank(&repo, candidates, limit, !self.candidates_only)?;
193
194 if self.candidates_only {
195 if as_json {
196 println!("{}", render_candidates_json(&items, self, limit));
197 } else {
198 let md = render_candidates_md(&items);
199 if !md.is_empty() {
200 print!("{}", md);
201 }
202 }
203 return Ok(());
204 }
205
206 let items = apply_budget(items, self.budget_chars);
207
208 let md = render_md(&items);
209 if as_json {
210 println!("{}", render_json(&items, &md, self, limit));
211 } else {
212 if !md.is_empty() {
213 print!("{}", md);
214 }
215 }
216
217 Ok(())
218 }
219}
220
221impl Context {

Calls 9

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
resolve_and_rankFunction · 0.85
render_candidates_mdFunction · 0.85
apply_budgetFunction · 0.85
render_mdFunction · 0.85
gather_candidatesMethod · 0.80
containsMethod · 0.45
is_emptyMethod · 0.45