At least for a subset of Python CLI programs, I wrote this: https://github.com/AdrianVollmer/pycompgen

Still in an early stage, but it should work.