diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2010-08-20 09:30:37 -0600 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2010-08-20 09:30:37 -0600 |
commit | b063d3b8dfb0f2f02c389617a1174b182a867bb0 (patch) | |
tree | 03ee60f386a666f52fddff8748e7254a97fafe79 /src | |
parent | 8a5eea5ef1d9d2cb8275044a1a3071bd80adef03 (diff) |
Fix bug 438; add support for listing available templates
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 1 | ||||
-rw-r--r-- | src/rebar_templater.erl | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 5486af6..f48ac92 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -207,6 +207,7 @@ compile Compile sources create template= [var=foo,...] Create skel based on template and vars create-app [appid=myapp] Create simple app skel create-node [nodeid=mynode] Create simple node skel +list-templates List available templates doc Generate Erlang program documentation diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index fd1d813..e338455 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -28,6 +28,7 @@ -export(['create-app'/2, 'create-node'/2, + 'list-templates'/2, create/2]). -include("rebar.hrl"). @@ -48,6 +49,20 @@ rebar_config:set_global(template, "simplenode"), create(Config, File). +'list-templates'(_Config, _File) -> + %% Load a list of all the files in the escript -- cache it in the pdict + %% since we'll potentially need to walk it several times over the course + %% of a run. + cache_escript_files(), + + %% Build a list of available templates + AvailTemplates = find_disk_templates() ++ find_escript_templates(), + ?CONSOLE("Available templates:\n", []), + [?CONSOLE("\t* ~s: ~s (~p)\n", [filename:basename(F, ".template"), F, Type]) || + {Type, F} <- AvailTemplates], + ok. + + create(_Config, _) -> %% Load a list of all the files in the escript -- cache it in the pdict %% since we'll potentially need to walk it several times over the course |