This patch makes a small change in rebar_core that checks the list
of valid plugins to see if any of them export a pre/post processing
function for the current command. This logic is applied only to the
plugins and allows plugin authors to hook into rebar's execution by
using a naming convention that matches the one used for scripting hooks.
Example:
```erlang
-module(my_rebar_plugin).
-export([pre_compile/2]).
pre_compile(Config, AppFile) ->
rebar_log:log(debug, "PRECOMPILE: ~p:~p~n",
[AppFile, Config]),
ok.
```
This change makes it possible to assign pre/post scripts to all
rebar commands. This allows users fine grained control over
when scripts and/or shell commands should be executed, where such
extensions are absolutely needed.
Several examples have been added to the rebar.config.sample file.
Rebar will exit with {error,bad_directory} when trying to restore the code
path after it has finished working on a subdirectory if there are invalid
relative paths in it. The problem was seen when executing the last line of
rebar_erlc_compiler:doterl_compile/3 (true = code:set_path(CurrPath)).
This change makes it possible to type the beginning (the prefix) of a
command name and rebar will guess the full name of the command,
thereby saving the user precious keystrokes. As long as the prefix
matches only one command, rebar runs that command, otherwise rebar
prints a list of candidate command names. The "-" character is
considered to be a word separator and the prefix matching is done per
word.
Example prefix matches:
co ==> compile
cl ==> clean
create ==> create
create-a ==> create-app
c-a ==> create-app
c-app ==> create-app
Rebar currently doesn't give any feedback on an invalid command. This change
makes rebar keep track of how many operations each command triggers, if a
particular command doesn't change the count, there were no modules implementing
it. If at the end of handling all commands, tje count is 0, none of the supplied
commands were valid and ?FAIL is called to trigger a non zero exit status.