mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Simplify rebar_core
This commit is contained in:
parent
27019e2867
commit
932eb2e343
1 changed files with 17 additions and 23 deletions
|
@ -120,7 +120,7 @@ parse_args(Args) ->
|
||||||
case getopt:parse(OptSpecList, Args) of
|
case getopt:parse(OptSpecList, Args) of
|
||||||
{ok, {Options, NonOptArgs}} ->
|
{ok, {Options, NonOptArgs}} ->
|
||||||
%% Check options and maybe halt execution
|
%% Check options and maybe halt execution
|
||||||
{ok, continue} = show_info_maybe_halt(Options, NonOptArgs),
|
ok = show_info_maybe_halt(Options, NonOptArgs),
|
||||||
|
|
||||||
%% Set global variables based on getopt options
|
%% Set global variables based on getopt options
|
||||||
set_global_flag(Options, verbose),
|
set_global_flag(Options, verbose),
|
||||||
|
@ -165,31 +165,25 @@ set_global_flag(Options, Flag) ->
|
||||||
%% show info and maybe halt execution
|
%% show info and maybe halt execution
|
||||||
%%
|
%%
|
||||||
show_info_maybe_halt(Opts, NonOptArgs) ->
|
show_info_maybe_halt(Opts, NonOptArgs) ->
|
||||||
case proplists:get_bool(help, Opts) of
|
false = show_info_maybe_halt(help, Opts, fun help/0),
|
||||||
true ->
|
false = show_info_maybe_halt(commands, Opts, fun commands/0),
|
||||||
|
false = show_info_maybe_halt(version, Opts, fun version/0),
|
||||||
|
case NonOptArgs of
|
||||||
|
[] ->
|
||||||
|
?CONSOLE("No command to run specified!~n",[]),
|
||||||
help(),
|
help(),
|
||||||
|
halt(1);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
show_info_maybe_halt(O, Opts, F) ->
|
||||||
|
case proplists:get_bool(O, Opts) of
|
||||||
|
true ->
|
||||||
|
F(),
|
||||||
halt(0);
|
halt(0);
|
||||||
false ->
|
false ->
|
||||||
case proplists:get_bool(commands, Opts) of
|
false
|
||||||
true ->
|
|
||||||
commands(),
|
|
||||||
halt(0);
|
|
||||||
false ->
|
|
||||||
case proplists:get_bool(version, Opts) of
|
|
||||||
true ->
|
|
||||||
version(),
|
|
||||||
halt(0);
|
|
||||||
false ->
|
|
||||||
case NonOptArgs of
|
|
||||||
[] ->
|
|
||||||
?CONSOLE("No command to run specified!~n",[]),
|
|
||||||
help(),
|
|
||||||
halt(1);
|
|
||||||
_ ->
|
|
||||||
{ok, continue}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
Loading…
Reference in a new issue