diff options
-rw-r--r-- | src/rebar_prv_new.erl | 6 | ||||
-rw-r--r-- | src/rebar_templater.erl | 20 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl index e5233cd..528c95e 100644 --- a/src/rebar_prv_new.erl +++ b/src/rebar_prv_new.erl @@ -31,7 +31,11 @@ do(State) -> case rebar_state:command_args(State) of [TemplateName] -> Template = list_to_atom(TemplateName), - rebar_templater:new(Template, State), + rebar_templater:new(Template, "", State), + {ok, State}; + [TemplateName, DirName] -> + Template = list_to_atom(TemplateName), + rebar_templater:new(Template, DirName, State), {ok, State}; [] -> {ok, State} diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index f22329b..820bd0c 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -26,7 +26,7 @@ %% ------------------------------------------------------------------- -module(rebar_templater). --export([new/2, +-export([new/3, list_templates/1, create/1]). @@ -42,13 +42,13 @@ %% Public API %% =================================================================== -new(app, Config) -> - create1(Config, "simpleapp"); -new(lib, Config) -> - create1(Config, "simplelib"); -new(node, Config) -> +new(app, DirName, Config) -> + create1(Config, DirName, "simpleapp"); +new(lib, DirName, Config) -> + create1(Config, DirName, "simplelib"); +new(node, DirName, Config) -> %% Alias for create w/ template=simplenode - create1(Config, "simplenode"). + create1(Config, DirName, "simplenode"). list_templates(Config) -> {AvailTemplates, Files} = find_templates(Config), @@ -69,7 +69,7 @@ list_templates(Config) -> create(Config) -> TemplateId = template_id(Config), - create1(Config, TemplateId). + create1(Config, "", TemplateId). %% %% Given a list of key value pairs, for each string value attempt to @@ -100,7 +100,9 @@ render(Bin, Context) -> %% Internal functions %% =================================================================== -create1(Config, TemplateId) -> +create1(Config, AppDir, TemplateId) -> + ec_file:mkdir_p(AppDir), + file:set_cwd(AppDir), {AvailTemplates, Files} = find_templates(Config), ?DEBUG("Available templates: ~p\n", [AvailTemplates]), |