moving cli code to functions/cli, update #2388