diff options
| author | Fred Hebert <mononcqc@ferd.ca> | 2015-03-25 09:44:43 -0700 | 
|---|---|---|
| committer | Fred Hebert <mononcqc@ferd.ca> | 2015-03-25 09:48:24 -0700 | 
| commit | d191edddb46d8e1a090fd2b1230ce3597a011b25 (patch) | |
| tree | cb6cee460b8c2a062c7a6a9ac8f847824e37e173 /src | |
| parent | 61455c04d01b07aa9a12368091259bbb840e836a (diff) | |
Polish rough edges of 'new' provider
- Allow 'rebar3 help' to work and have it point to 'rebar3 help
  <template>'
- show a 'template not found' message when a template is indeed not
  found rather than crashing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rebar_prv_new.erl | 15 | 
1 files changed, 12 insertions, 3 deletions
| diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl index 77e100f..58e27fd 100644 --- a/src/rebar_prv_new.erl +++ b/src/rebar_prv_new.erl @@ -33,15 +33,24 @@ init(State) ->  -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.  do(State) ->      case rebar_state:command_args(State) of +        ["help"] -> +            ?CONSOLE("Call `rebar3 new help <template>` for a detailed description~n", []), +            show_short_templates(rebar_templater:list_templates(State)), +            {ok, State};          ["help", TemplateName] ->              case lists:keyfind(TemplateName, 1, rebar_templater:list_templates(State)) of -                false -> io:format("template not found.~n"); +                false -> ?CONSOLE("template not found.", []);                  Term -> show_template(Term)              end,              {ok, State};          [TemplateName | Opts] -> -            Force = is_forced(State), -            ok = rebar_templater:new(TemplateName, parse_opts(Opts), Force, State), +            case lists:keyfind(TemplateName, 1, rebar_templater:list_templates(State)) of +                false -> +                    ?CONSOLE("template not found.", []); +                _ -> +                    Force = is_forced(State), +                    ok = rebar_templater:new(TemplateName, parse_opts(Opts), Force, State) +            end,              {ok, State};          [] ->              show_short_templates(rebar_templater:list_templates(State)), | 
