summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2019-05-12 14:11:25 -0600
committerTristan Sloughter <t@crashfast.com>2019-05-13 07:36:36 -0600
commit1467cd61fd7445bf3df6240eceb3e3cd5cbd470b (patch)
tree09312626bab3dcc6c27144a5c71d819871a4dd56
parentaf9d2086b33997c16bafe02dcd5bcd9453407849 (diff)
add support for usage message after template is done
-rw-r--r--src/rebar_templater.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index bc79db0..f74b12f 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -162,7 +162,14 @@ create({Template, Type, File}, Files, UserVars, Force, State) ->
Vars = drop_var_docs(override_vars(UserVars, get_template_vars(TemplateTerms, State))),
maybe_warn_about_name(Vars),
TemplateCwd = filename:dirname(File),
- execute_template(TemplateTerms, Files, {Template, Type, TemplateCwd}, Vars, Force).
+ Result = execute_template(TemplateTerms, Files, {Template, Type, TemplateCwd}, Vars, Force),
+ maybe_print_final_message(proplists:get_value(message, TemplateTerms, undefined), Vars),
+ Result.
+
+maybe_print_final_message(undefined, _) ->
+ ok;
+maybe_print_final_message(Message, Values) ->
+ io:format("~s~n", [render(Message, Values)]).
maybe_warn_about_name(Vars) ->
Name = proplists:get_value(name, Vars, "valid"),
@@ -198,6 +205,9 @@ execute_template([{description, _} | Terms], Files, Template, Vars, Force) ->
%% We can't execute variables
execute_template([{variables, _} | Terms], Files, Template, Vars, Force) ->
execute_template(Terms, Files, Template, Vars, Force);
+%% We can't execute message
+execute_template([{message, _} | Terms], Files, Template, Vars, Force) ->
+ execute_template(Terms, Files, Template, Vars, Force);
%% Create a directory
execute_template([{dir, Path} | Terms], Files, Template, Vars, Force) ->
?DEBUG("Creating directory ~p", [Path]),