`query code` uses the same graph-filtered read over both local-service and reactor transports. Preserve the complete domain JSON/human render.
(args: &super::query::QueryCode)
| 6874 | /// `query code` uses the same graph-filtered read over both local-service and |
| 6875 | /// reactor transports. Preserve the complete domain JSON/human render. |
| 6876 | pub fn query_code(args: &super::query::QueryCode) -> CliResult<bool> { |
| 6877 | let Some(session) = Service::open()? else { |
| 6878 | return Ok(false); |
| 6879 | }; |
| 6880 | let response = session.query_graph(pb::QueryGraphRequest { |
| 6881 | repository: Some(session.reference.clone()), |
| 6882 | query: Some(pb::query_graph_request::Query::ContentSearch( |
| 6883 | pb::ContentSearchQuery { |
| 6884 | query: args.pattern.clone(), |
| 6885 | paths: Vec::new(), |
| 6886 | path_filter: args.path_filter.clone(), |
| 6887 | file_type: args.file_type.clone(), |
| 6888 | exclude_type: None, |
| 6889 | case_insensitive: args.case_insensitive, |
| 6890 | max_results: Some(u32::try_from(args.max_results).map_err(|_| { |
| 6891 | CliError::Internal(anyhow::anyhow!("max-results exceeds the RPC limit")) |
| 6892 | })?), |
| 6893 | }, |
| 6894 | )), |
| 6895 | ..Default::default() |
| 6896 | })?; |
| 6897 | let result = response.content_result.ok_or_else(|| { |
| 6898 | CliError::Internal(anyhow::anyhow!( |
| 6899 | "the service returned no content search result" |
| 6900 | )) |
| 6901 | })?; |
| 6902 | let result = atomic_repository::ContentSearchResult { |
| 6903 | matches: result |
| 6904 | .matches |
| 6905 | .into_iter() |
| 6906 | .map(|m| atomic_repository::ContentMatch { |
| 6907 | path: m.path, |
| 6908 | line_number: m.line_number, |
| 6909 | line_content: m.line_content, |
| 6910 | byte_offset: m.byte_offset, |
| 6911 | submatch_start: m.submatch_start as usize, |
| 6912 | submatch_end: m.submatch_end as usize, |
| 6913 | }) |
| 6914 | .collect(), |
| 6915 | total_matches: result.total_matches as usize, |
| 6916 | dir_facets: result |
| 6917 | .dir_facets |
| 6918 | .into_iter() |
| 6919 | .map(|facet| (facet.path, facet.count as usize)) |
| 6920 | .collect(), |
| 6921 | }; |
| 6922 | super::query::print_code_result(&result, args.json)?; |
| 6923 | Ok(true) |
| 6924 | } |
| 6925 | |
| 6926 | /// `atomic query plan` over QueryGraph (Plan) — the structured plan |
| 6927 | /// executes handler-side; the CLI renders the domain PlanResult JSON |
no test coverage detected