Removing code duplication in CLI class.

A little metaprogramming never hurt anybody, right?