CLI: some refactoring