ud-generate: Move main code into a ud_generate()