Expand CLI functionality and move it into a function.