[WIP] Beginning refactoring for new CLI.

This is the beginning of an implementation of #92.