[CLI-11] All code minus a unit test.