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

Method run

atomic-cli/src/commands/vault/context.rs:172–217  ·  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 = Repository::open_readonly(&root).map_err(CliError::Repository)?;
188
189 let limit = self.limit;
190 let candidates = self.gather_candidates(&repo, limit)?;
191 let items = resolve_and_rank(&repo, candidates, limit, !self.candidates_only)?;
192
193 if self.candidates_only {
194 if as_json {
195 println!("{}", render_candidates_json(&items, self, limit));
196 } else {
197 let md = render_candidates_md(&items);
198 if !md.is_empty() {
199 print!("{}", md);
200 }
201 }
202 return Ok(());
203 }
204
205 let items = apply_budget(items, self.budget_chars);
206
207 let md = render_md(&items);
208 if as_json {
209 println!("{}", render_json(&items, &md, self, limit));
210 } else {
211 if !md.is_empty() {
212 print!("{}", md);
213 }
214 }
215
216 Ok(())
217 }
218}
219
220impl Context {

Calls 8

find_repository_rootFunction · 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