Move command into cli, separate functions