diff options
Diffstat (limited to 'src/rebar.erl')
-rw-r--r-- | src/rebar.erl | 154 |
1 files changed, 104 insertions, 50 deletions
diff --git a/src/rebar.erl b/src/rebar.erl index 1902f14..36a7b36 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -87,7 +87,9 @@ run(["help"|RawCmds]) when RawCmds =/= [] -> run(["help"]) -> help(); run(["info"|_]) -> - help(); + %% Catch calls to 'rebar info' to avoid treating plugins' info/2 functions + %% as commands. + ?CONSOLE("Command 'info' not understood or not applicable~n", []); run(["version"]) -> ok = load_rebar_app(), %% Display vsn and build time info @@ -178,14 +180,26 @@ run_aux(BaseConfig, Commands) -> %% help() -> OptSpecList = option_spec_list(), - getopt:usage(OptSpecList, "rebar", - "[var=value,...] <command,...>", - [{"var=value", "rebar global variables (e.g. force=1)"}, - {"command", "Command to run (e.g. compile)"}]), + rebar_getopt:usage(OptSpecList, "rebar", + "[var=value,...] <command,...>", + [{"var=value", "rebar global variables (e.g. force=1)"}, + {"command", "Command to run (e.g. compile)"}]), + + ?CONSOLE("To see a list of built-in commands, execute rebar -c.~n~n", []), ?CONSOLE( "Type 'rebar help <CMD1> <CMD2>' for help on specific commands." "~n~n", []), ?CONSOLE( + "rebar allows you to abbreviate the command to run:~n" + "$ rebar co # same as rebar compile~n" + "$ rebar eu # same as rebar eunit~n" + "$ rebar g-d # same as rebar get-deps~n" + "$ rebar x eu # same as rebar xref eunit~n" + "$ rebar l-d # same as rebar list-deps~n" + "$ rebar l-d l-t # same as rebar list-deps list-templates~n" + "$ rebar list-d l-te # same as rebar list-deps list-templates~n" + "~n", []), + ?CONSOLE( "Core rebar.config options:~n" " ~p~n" " ~p~n" @@ -215,7 +229,7 @@ help() -> parse_args(RawArgs) -> %% Parse getopt options OptSpecList = option_spec_list(), - case getopt:parse(OptSpecList, RawArgs) of + case rebar_getopt:parse(OptSpecList, RawArgs) of {ok, Args} -> Args; {error, {Reason, Data}} -> @@ -258,13 +272,27 @@ save_options(Config, {Options, NonOptArgs}) -> %% set log level based on getopt option %% set_log_level(Config, Options) -> - LogLevel = case proplists:get_all_values(verbose, Options) of - [] -> - rebar_log:default_level(); - Verbosities -> - lists:last(Verbosities) - end, - rebar_config:set_global(Config, verbose, LogLevel). + {IsVerbose, Level} = + case proplists:get_bool(quiet, Options) of + true -> + {false, rebar_log:error_level()}; + false -> + DefaultLevel = rebar_log:default_level(), + case proplists:get_all_values(verbose, Options) of + [] -> + {false, DefaultLevel}; + Verbosities -> + {true, DefaultLevel + lists:last(Verbosities)} + end + end, + + case IsVerbose of + true -> + Config1 = rebar_config:set_xconf(Config, is_verbose, true), + rebar_config:set_global(Config1, verbose, Level); + false -> + rebar_config:set_global(Config, verbose, Level) + end. %% %% show version information and halt @@ -317,50 +345,54 @@ show_info_maybe_halt(O, Opts, F) -> %% commands() -> S = <<" -clean Clean -compile Compile sources +clean Clean +compile Compile sources -escriptize Generate escript archive +escriptize Generate escript archive -create template= [var=foo,...] Create skel based on template and vars -create-app [appid=myapp] Create simple app skel -create-node [nodeid=mynode] Create simple node skel -list-templates List available templates +create template= [var=foo,...] Create skel based on template and vars +create-app [appid=myapp] Create simple app skel +create-lib [libid=mylib] Create simple lib skel +create-node [nodeid=mynode] Create simple node skel +list-templates List available templates -doc Generate Erlang program documentation +doc Generate Erlang program documentation -check-deps Display to be fetched dependencies -get-deps Fetch dependencies -update-deps Update fetched dependencies -delete-deps Delete fetched dependencies -list-deps List dependencies +check-deps Display to be fetched dependencies +get-deps Fetch dependencies +update-deps Update fetched dependencies +delete-deps Delete fetched dependencies +list-deps List dependencies -generate [dump_spec=0/1] Build release with reltool -overlay Run reltool overlays only +generate [dump_spec=0/1] Build release with reltool +overlay Run reltool overlays only generate-upgrade previous_release=path Build an upgrade package generate-appups previous_release=path Generate appup files -eunit [suites=foo] Run eunit tests in foo.erl and - test/foo_tests.erl - [suites=foo] [tests=bar] Run specific eunit tests [first test name - starting with 'bar' in foo.erl and - test/foo_tests.erl] - [tests=bar] For every existing suite, run the first - test whose name starts with bar and, if - no such test exists, run the test whose - name starts with bar in the suite's - _tests module +eunit [suite[s]=foo] Run EUnit tests in foo.erl and + test/foo_tests.erl + [suite[s]=foo] [test[s]=bar] Run specific EUnit tests [first test + name starting with 'bar' in foo.erl + and test/foo_tests.erl] + [test[s]=bar] For every existing suite, run the first + test whose name starts with bar and, if + no such test exists, run the test whose + name starts with bar in the suite's + _tests module. + [random_suite_order=true] Run tests in a random order, either + [random_suite_order=Seed] with a random seed for the PRNG, or a + specific one. -ct [suites=] [case=] Run common_test suites +ct [suite[s]=] [case=] Run common_test suites -qc Test QuickCheck properties +qc Test QuickCheck properties -xref Run cross reference analysis +xref Run cross reference analysis -help Show the program options -version Show version information +help Show the program options +version Show version information ">>, io:put_chars(S). @@ -375,12 +407,12 @@ option_spec_list() -> JobsHelp = io_lib:format( "Number of concurrent workers a command may use. Default: ~B", [Jobs]), - VerboseHelp = "Verbosity level (-v, -vv, -vvv, --verbose 3). Default: 0", [ %% {Name, ShortOpt, LongOpt, ArgSpec, HelpMsg} {help, $h, "help", undefined, "Show the program options"}, {commands, $c, "commands", undefined, "Show available commands"}, - {verbose, $v, "verbose", integer, VerboseHelp}, + {verbose, $v, "verbose", integer, "Verbosity level (-v, -vv)"}, + {quiet, $q, "quiet", boolean, "Quiet, only print error messages"}, {version, $V, "version", undefined, "Show version information"}, {force, $f, "force", undefined, "Force"}, {defines, $D, undefined, string, "Define compiler macro"}, @@ -417,11 +449,33 @@ filter_flags(Config, [Item | Rest], Commands) -> end. command_names() -> - ["check-deps", "clean", "compile", "create", "create-app", "create-node", - "ct", "delete-deps", "doc", "eunit", "escriptize", "generate", - "generate-appups", "generate-upgrade", "get-deps", "help", "list-deps", - "list-templates", "qc", "update-deps", "overlay", "shell", "version", - "xref"]. + [ + "check-deps", + "clean", + "compile", + "create", + "create-app", + "create-lib", + "create-node", + "ct", + "delete-deps", + "doc", + "eunit", + "escriptize", + "generate", + "generate-appups", + "generate-upgrade", + "get-deps", + "help", + "list-deps", + "list-templates", + "qc", + "update-deps", + "overlay", + "shell", + "version", + "xref" + ]. unabbreviate_command_names([]) -> []; |