And while it's not it's primary purpose, Lucene comes with some CLI programs[2]. They are there mainly as a demo, but if you feel like writing some code you might be able to adapt that to your needs.
[1]: https://www.esa.org/tiee/search/html/readme.html
[2]: https://lucene.apache.org/core/3_5_0/demo.html