mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Warn when a command is not implemented. Fail when no supplied commands are implemented
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.
This commit is contained in:
parent
ce74846e4e
commit
24cc775e88
1 changed files with 21 additions and 1 deletions
|
@ -79,6 +79,9 @@ run(RawArgs) ->
|
||||||
%% Note the top-level directory for reference
|
%% Note the top-level directory for reference
|
||||||
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
||||||
|
|
||||||
|
%% Keep track of how many operations we do, so we can detect bad commands
|
||||||
|
erlang:put(operations, 0),
|
||||||
|
|
||||||
%% Process each command, resetting any state between each one
|
%% Process each command, resetting any state between each one
|
||||||
process_commands(CommandAtoms).
|
process_commands(CommandAtoms).
|
||||||
|
|
||||||
|
@ -275,12 +278,26 @@ filter_flags([Item | Rest], Commands) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
process_commands([]) ->
|
process_commands([]) ->
|
||||||
ok;
|
case erlang:get(operations) of
|
||||||
|
0 ->
|
||||||
|
%% none of the commands had an effect
|
||||||
|
?FAIL;
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
process_commands([Command | Rest]) ->
|
process_commands([Command | Rest]) ->
|
||||||
%% Reset skip dirs
|
%% Reset skip dirs
|
||||||
[erlang:erase({skip_dir, D}) || D <- skip_dirs()],
|
[erlang:erase({skip_dir, D}) || D <- skip_dirs()],
|
||||||
|
Operations = erlang:get(operations),
|
||||||
|
|
||||||
process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()),
|
process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()),
|
||||||
|
case erlang:get(operations) of
|
||||||
|
Operations ->
|
||||||
|
%% This command didn't do anything
|
||||||
|
?CONSOLE("Command '~p' not understood\n", [Command]);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
process_commands(Rest).
|
process_commands(Rest).
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,6 +434,9 @@ execute(Command, Modules, Config, ModuleFile) ->
|
||||||
Dir = rebar_utils:get_cwd(),
|
Dir = rebar_utils:get_cwd(),
|
||||||
?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
|
?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
|
||||||
|
|
||||||
|
%% Increment the count of operations, since some module responds to this command
|
||||||
|
erlang:put(operations, erlang:get(operations) + 1),
|
||||||
|
|
||||||
%% Run the available modules
|
%% Run the available modules
|
||||||
case catch(run_modules(TargetModules, Command, Config, ModuleFile)) of
|
case catch(run_modules(TargetModules, Command, Config, ModuleFile)) of
|
||||||
ok ->
|
ok ->
|
||||||
|
|
Loading…
Reference in a new issue