Fix #1 and add command line generate method.