diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2019-05-31 05:45:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 05:45:34 -0700 |
commit | 19aa7d3afbcf2e8a53137ed005ef5434fd1729ec (patch) | |
tree | 4bd972b276d875a371695c3ea11c230ea982d217 /src | |
parent | eea09f13065df68345f226dad43feae326c999fc (diff) | |
parent | 1467cd61fd7445bf3df6240eceb3e3cd5cbd470b (diff) |
Merge pull request #2075 from tsloughter/tmpl-usage
add support for usage message after template is done
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_templater.erl | 12 |
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]), |