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

Method run

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

Source from the content-addressed store, hash-verified

149
150impl Command for Context {
151 fn run(&self) -> CliResult<()> {
152 let as_json = self.json || self.format.eq_ignore_ascii_case("json");
153 if !as_json && !self.format.eq_ignore_ascii_case("md") {
154 return Err(CliError::InvalidArgument {
155 message: format!("Unknown format: {} (expected md or json)", self.format),
156 });
157 }
158
159 if !(1..=MAX_LIMIT).contains(&self.limit) {
160 return Err(CliError::InvalidArgument {
161 message: format!("--limit must be between 1 and {MAX_LIMIT}"),
162 });
163 }
164
165 let root = find_repository_root()?;
166 let repo = Repository::open_readonly(&root).map_err(CliError::Repository)?;
167
168 let limit = self.limit;
169 let candidates = self.gather_candidates(&repo, limit)?;
170 let items = resolve_and_rank(&repo, candidates, limit)?;
171 let items = apply_budget(items, self.budget_chars);
172
173 let md = render_md(&items);
174 if as_json {
175 println!("{}", render_json(&items, &md, self, limit));
176 } else {
177 if !md.is_empty() {
178 print!("{}", md);
179 }
180 }
181
182 Ok(())
183 }
184}
185
186impl Context {

Calls 7

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