Refactor cli open