full rewrite to normalize CLI and improve validation