- Provide a simple way to define and run project skeletons and other code generators.
- Help integrate later changes to the generators into a project.
Put the skeleton in a git repo. Before testing it, make sure to at least
git add the files. Then:
codger gen path/to/your/repo path/to/new/project
Here's how the skeleton repo will be used:
- If there is a script named
generate.rbin the root directory, it will be run.
- Files ending in
.erbwill be interpolated and written to the target directory.
- Other files will be copied directly to the target directory. (Exceptions: README, README.md, README.markdown, .gitignore)
In the templates or generate.rb, use the method
param :parameter_name to request values to configure the skeleton. The first time a particular parameter is requested, the user will be prompted for a value.
The first time a prompt is given, the skeleton repo's README will be printed (if it exists).
- In a template, you can use
<%- rename "relative_path" -%>to override the output file name.
copy "path1", "path2"to copy files "path1" and "path2" (relative the skeleton repo's root directory) into the target directory directly. Use
copy "path1" => "newpath1"to override the destination path in the target directory.
interpolate "path1", "path2"to interpolate ERB files "path1" and "path2" into the target directory. As with
copyyou can use a hash to override the destination paths.
cancelinside a template to stop its interpolation.
ignore "path1", "path2"to prevent automatic copying or interpolation of files.
Run in a new folder:
codger gen boilerplate monumental-endeavor
Or run in the current working directory:
codger gen boilerplate
codger cache git://uri/to/boilerplate.git # stores a local clone in ~/.codger/cached codger gen boilerplate # uses the local clone (but will update it first if possible)
You can add the
-r (record) option:
codger gen boilerplate -r
to have the run recorded in a file named
.codger, so that later, after the project or the skeleton have changed, you can use
to compare the current state of your project with the output of the current version of the skeleton. The command used for diffing can be changed:
codger config diff "diff -ur %SOURCE %DEST"
- Better documentation; examples
- I'm hopeful that more useful diffing can be done through git integration, but I haven't worked on it much yet.
- Code generators shouldn't be restricted to whatever dependencies happen to be pulled in by codger.