CLI tool refactoring