cli: convert to getopt.

only --help and --direct are getopts now. The rest are addressed
from optind which makes the logic a lot simpler. From there
we just pass char* to all the commands, which removes a lot
of math/magic and makes this more self-contained.