There is a project called Fig that lets add autocompletion support into your terminal very easily. By default, it has autocompletion support for variety of tools but it designed to be an extended way to let you add your CLI autocompletion support into it. They have a very detailed documentation to explain how you can do it if you develop your CLI tool with a popular tool called cobra.
This repository provides an autocompletion generation code for opa CLI basically. You can find out the generated autocompletion code, please reach out the official Figs' autocomplete repository.