From 1467cd61fd7445bf3df6240eceb3e3cd5cbd470b Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 12 May 2019 14:11:25 -0600 Subject: add support for usage message after template is done --- src/rebar_templater.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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]), -- cgit v1.1