cli: refactor and use $cmddef directly