Refactor Python cli