refactor cli functionality to its own module