There are 3 ways to parse parameters for your CLI written by bash: position based parameter, getopts and getopt. With no doubt, getopt is the most powerful one.

I will use db-helper command from killbill to show you how to use getopt.

The first thing you should know is getopt is not internal command for bash, if you want to use it, you have to make sure it is installed, and gnu-getopt is more powerful than bsd-getopt, which means, if you are using Mac OS X, you need to replace it with gnu-getopt.

Next is to think about parameters you want to use. You can use short parameter name like -a, -d, or long parameter name like --action, --database. Also, you can use both.

Parameter can be a switch like --rm, or a value like --host.