Might be interesting to use https://github.com/ejgallego/coq-serapi instead of talking to coqtop directly.