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

Function print_code_result

atomic-cli/src/commands/query/mod.rs:1578–1621  ·  view source on GitHub ↗
(
    result: &atomic_repository::ContentSearchResult,
    json: bool,
)

Source from the content-addressed store, hash-verified

1576}
1577
1578pub(crate) fn print_code_result(
1579 result: &atomic_repository::ContentSearchResult,
1580 json: bool,
1581) -> CliResult<()> {
1582 if json {
1583 println!("{}", serde_json::to_string_pretty(&result).unwrap());
1584 } else if result.matches.is_empty() {
1585 println!("No matches found.");
1586 } else {
1587 // Show matches
1588 let mut files = std::collections::HashSet::new();
1589 for m in &result.matches {
1590 files.insert(m.path.as_str());
1591 println!(
1592 "{}:{}: {}",
1593 m.path,
1594 m.line_number,
1595 m.line_content.trim_end()
1596 );
1597 }
1598
1599 // Summary
1600 println!(
1601 "\n{} match(es) in {} file(s).",
1602 result.matches.len(),
1603 files.len()
1604 );
1605
1606 // Show total and facets when results were truncated
1607 if result.total_matches > result.matches.len() {
1608 println!(
1609 " ({} total matches — showing top {}. Narrow with -g or -t.)\n",
1610 result.total_matches,
1611 result.matches.len()
1612 );
1613 println!(" Top directories:");
1614 for (dir, count) in &result.dir_facets {
1615 println!(" {:<40} {} matches", format!("-g \"{}\"", dir), count);
1616 }
1617 }
1618 }
1619
1620 Ok(())
1621}
1622
1623// ---------------------------------------------------------------------------
1624// QueryIndex — build / rebuild the content search index

Callers 2

query_codeFunction · 0.85
runMethod · 0.85

Calls 4

is_emptyMethod · 0.45
insertMethod · 0.45
as_strMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected