I would actually advise against building this, as tree-sitter is getting tag support, which covers this exact need. There should be C/Rust and JS bindings, but no cmd output. But it should be simple to create that on top.