diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-08-23 14:38:48 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-08-23 14:38:48 -0500 |
commit | 1afdd380d3e9c4fed717d6aaf05c5ad4a1b52322 (patch) | |
tree | 5569a6d8890fc9e5fe069b740789ede6a0a9fdc5 /src/rebar_prv_new.erl | |
parent | 5bb99b81db5f0b153282409d1fcf635b290e979f (diff) |
add back templating
Diffstat (limited to 'src/rebar_prv_new.erl')
-rw-r--r-- | src/rebar_prv_new.erl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl new file mode 100644 index 0000000..e5233cd --- /dev/null +++ b/src/rebar_prv_new.erl @@ -0,0 +1,69 @@ +-module(rebar_prv_new). + +-behaviour(rebar_provider). + +-export([init/1, + do/1]). + +-include("rebar.hrl"). + +-define(PROVIDER, new). +-define(DEPS, []). + +%% =================================================================== +%% Public API +%% =================================================================== + +-spec init(rebar_state:t()) -> {ok, rebar_state:t()}. +init(State) -> + State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER, + provider_impl = ?MODULE, + bare = false, + deps = ?DEPS, + example = "rebar new <template>", + short_desc = "", + desc = info(create), + opts = []}), + {ok, State1}. + +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. +do(State) -> + case rebar_state:command_args(State) of + [TemplateName] -> + Template = list_to_atom(TemplateName), + rebar_templater:new(Template, State), + {ok, State}; + [] -> + {ok, State} + end. + +%% =================================================================== +%% Internal functions +%% =================================================================== + +info(create) -> + io_lib:format( + "Create skel based on template and vars.~n" + "~n" + "Valid command line options:~n" + " template= [var=foo,...]~n", []); +info(create_app) -> + io_lib:format( + "Create simple app skel.~n" + "~n" + "Valid command line options:~n" + " [appid=myapp]~n", []); +info(create_lib) -> + io_lib:format( + "Create simple lib skel.~n" + "~n" + "Valid command line options:~n" + " [libid=mylib]~n", []); +info(create_node) -> + io_lib:format( + "Create simple node skel.~n" + "~n" + "Valid command line options:~n" + " [nodeid=mynode]~n", []); +info(list_templates) -> + io_lib:format("List available templates.~n", []). |