To use bash completion, compile the above program as sample , put sample on your $PATH , and then run:
sample --help=bash > sample.comp source sample.comp
Now you can enter sample --ver , click the tab, and it will complete before sample --version .
There are several inaccuracies in the end, in particular, the program should be on your $PATH , and if you are on Windows, you need to run sample.comp through dos2unix . It is also completely undocumented, which must be fixed by the package author.
source share