[cli] Refactored main