refactor cli into own lib