Yeoman describes itself as a "scaffolding tool for modern webapps", but I have used it for a general code generation tool with its ability to create custom generators.
Generators have a well-defined lifecycle. In the prompting stage, if desired, Yeoman can prompt you with different questions that it will use in later stages. You can include a set of static files for Yeoman to copy into the new project, as well as dynamic templates that Yeoman will fill with the answers to the questions, computed values, or arguments from the command line.
Yeoman is written in JavaScript and was originally intended for JavaScript, but it can definitely be used for generating code for other languages.