MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / highlight_json

Function highlight_json

crates/chat-cli/src/cli/chat/cli/profile.rs:499–515  ·  view source on GitHub ↗
(output: &mut impl Write, json_str: &str)

Source from the content-addressed store, hash-verified

497}
498
499fn highlight_json(output: &mut impl Write, json_str: &str) -> eyre::Result<()> {
500 let ps = SyntaxSet::load_defaults_newlines();
501 let ts = ThemeSet::load_defaults();
502
503 let syntax = ps
504 .find_syntax_by_extension("json")
505 .ok_or(eyre::eyre!("No syntax found by extension"))?;
506 let mut h = HighlightLines::new(syntax, &ts.themes["base16-ocean.dark"]);
507
508 for line in LinesWithEndings::from(json_str) {
509 let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ps)?;
510 let escaped = as_24_bit_terminal_escaped(&ranges[..], false);
511 queue!(output, style::Print(escaped))?;
512 }
513
514 Ok(execute!(output, StyledText::reset())?)
515}
516
517/// Searches all configuration sources for MCP servers and returns a deduplicated list.
518/// Priority order: Agent configs > Workspace legacy > Global legacy

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected