moved cli code to separate file.