To use the completion it just needs to be placed in the
/etc/bash_completion.d/ directory on Linux, or the
/usr/local/etc/bash_completion.d directory on macOS. On Linux the completion will be loaded automatically, but on macOS you need to
source the completion file in
.bashrc or your preferred file.
Automatic generation would be very cool, but if the completion has already been created it wouldn't take too much time to just add another case for each new command.