Extract cli to function