summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_api.erl20
-rw-r--r--src/rebar_app_info.erl2
-rw-r--r--src/rebar_prv_clean.erl2
-rw-r--r--src/rebar_prv_deps.erl2
-rw-r--r--src/rebar_prv_erlydtl_compiler.erl1
-rw-r--r--src/rebar_prv_escriptize.erl4
-rw-r--r--src/rebar_prv_help.erl4
-rw-r--r--src/rebar_prv_install_deps.erl4
-rw-r--r--src/rebar_prv_new.erl17
-rw-r--r--src/rebar_prv_wtf.erl4
-rw-r--r--src/rebar_prv_xref.erl4
-rw-r--r--src/rebar_state.erl2
-rw-r--r--src/rebar_utils.erl5
13 files changed, 50 insertions, 21 deletions
diff --git a/src/rebar_api.erl b/src/rebar_api.erl
index a01391d..3fc7f61 100644
--- a/src/rebar_api.erl
+++ b/src/rebar_api.erl
@@ -5,7 +5,11 @@
-include_lib("providers/include/providers.hrl").
-export([abort/0, abort/2,
console/2,
- debug/2, info/2, warn/2, error/2]).
+ debug/2, info/2, warn/2, error/2,
+ expand_env_variable/3,
+ get_arch/0,
+ wordsize/0]).
+
-export_type([rebar_dict/0, rebar_digraph/0]).
%%%%%%%%%%%%%%%%%%%%%%%
@@ -30,3 +34,17 @@ info(Str, Args) -> ?INFO(Str, Args).
warn(Str, Args) -> ?WARN(Str, Args).
%% @doc logs with severity `error'
error(Str, Args) -> ?ERROR(Str, Args).
+
+%%
+%% Given env. variable FOO we want to expand all references to
+%% it in InStr. References can have two forms: $FOO and ${FOO}
+%% The end of form $FOO is delimited with whitespace or eol
+%%
+expand_env_variable(InStr, VarName, RawVarValue) ->
+ rebar_utils:expand_env_variable(InStr, VarName, RawVarValue).
+
+get_arch() ->
+ rebar_utils:get_arch().
+
+wordsize() ->
+ rebar_utils:wordsize().
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl
index 94c66db..9659c0b 100644
--- a/src/rebar_app_info.erl
+++ b/src/rebar_app_info.erl
@@ -49,7 +49,7 @@
app_details=[] :: list(),
applications=[] :: list(),
deps=[] :: list(),
- profiles=[default] :: atom(),
+ profiles=[default] :: [atom()],
dep_level=0 :: integer(),
dir :: file:name(),
out_dir :: file:name(),
diff --git a/src/rebar_prv_clean.erl b/src/rebar_prv_clean.erl
index 8fbc516..0da286b 100644
--- a/src/rebar_prv_clean.erl
+++ b/src/rebar_prv_clean.erl
@@ -37,7 +37,7 @@ do(State) ->
case All of
true ->
- DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
+ DepsDir = rebar_dir:deps_dir(State),
DepApps = rebar_app_discover:find_apps([DepsDir], all);
false ->
DepApps = []
diff --git a/src/rebar_prv_deps.erl b/src/rebar_prv_deps.erl
index cfa2d3f..f1697b6 100644
--- a/src/rebar_prv_deps.erl
+++ b/src/rebar_prv_deps.erl
@@ -74,7 +74,7 @@ display_dep(_State, {Name, _Vsn, Source}) when is_tuple(Source) ->
display_dep(_State, {Name, _Vsn, Source, _Opts}) when is_tuple(Source) ->
?CONSOLE("~s* (source ~p)", [ec_cnv:to_binary(Name), Source]);
%% Locked
-display_dep(State, {Name, Source={pkg, _, Vsn, _}, Level}) when is_integer(Level) ->
+display_dep(State, {Name, Source={pkg, _, Vsn}, Level}) when is_integer(Level) ->
DepsDir = rebar_dir:deps_dir(State),
AppDir = filename:join([DepsDir, ec_cnv:to_binary(Name)]),
NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source) of
diff --git a/src/rebar_prv_erlydtl_compiler.erl b/src/rebar_prv_erlydtl_compiler.erl
index db4dde2..79244ee 100644
--- a/src/rebar_prv_erlydtl_compiler.erl
+++ b/src/rebar_prv_erlydtl_compiler.erl
@@ -173,7 +173,6 @@ option(Opt, DtlOpts) ->
default(app) -> undefined;
default(doc_root) -> "priv/templates";
-default(out_dir) -> "ebin";
default(source_ext) -> ".dtl";
default(module_ext) -> "_dtl";
default(custom_tags_dir) -> "";
diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl
index d5708c5..d17699e 100644
--- a/src/rebar_prv_escriptize.erl
+++ b/src/rebar_prv_escriptize.erl
@@ -51,7 +51,7 @@ init(State) ->
{deps, ?DEPS},
{example, "rebar3 escriptize"},
{opts, []},
- {short_desc, "Generate escript archive"},
+ {short_desc, "Generate escript archive."},
{desc, desc()}
]),
{ok, rebar_state:add_provider(State, Provider)}.
@@ -69,7 +69,7 @@ escriptize(State0) ->
[App] ->
App;
Apps ->
- case rebar_state:get(escript_main_app, State0, undefined) of
+ case rebar_state:get(State0, escript_main_app, undefined) of
undefined ->
?PRV_ERROR(no_main_app);
Name ->
diff --git a/src/rebar_prv_help.erl b/src/rebar_prv_help.erl
index 9e22530..b450023 100644
--- a/src/rebar_prv_help.erl
+++ b/src/rebar_prv_help.erl
@@ -58,11 +58,11 @@ format_error(Reason) ->
%% print help/usage string
%%
help(State) ->
- ?CONSOLE("Rebar is a tool for working with Erlang projects.~n~n", []),
+ ?CONSOLE("Rebar3 is a tool for working with Erlang projects.~n~n", []),
OptSpecList = rebar3:global_option_spec_list(),
getopt:usage(OptSpecList, "rebar", "", []),
?CONSOLE("~nSeveral tasks are available:~n", []),
providers:help(rebar_state:providers(State)),
- ?CONSOLE("~nRun 'rebar help <TASK>' for details.~n~n", []).
+ ?CONSOLE("~nRun 'rebar3 help <TASK>' for details.~n~n", []).
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 8ac78bf..e92a3f0 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -346,7 +346,7 @@ handle_dep(AppInfo, SrcDeps, PkgDeps, SrcApps, Level, State, Locks) ->
,NewLocks}.
-spec handle_dep(rebar_state:t(), file:filename_all(), rebar_app_info:t(), list(), integer()) ->
- {rebar_app_info:t(), [rebar_app_info:t()], [pkg_dep()]}.
+ {rebar_app_info:t(), [rebar_app_info:t()], [pkg_dep()], [integer()]}.
handle_dep(State, DepsDir, AppInfo, Locks, Level) ->
Profiles = rebar_state:current_profiles(State),
Name = rebar_app_info:name(AppInfo),
@@ -402,7 +402,7 @@ in_default(AppInfo, State) ->
DefaultAppDir = filename:join([rebar_state:get(State, base_dir), "default", "lib", Name]),
rebar_app_discover:find_app(DefaultAppDir, all).
--spec parse_deps(binary(), list(), list(), list(), integer()) -> {[rebar_app_info:t()], [pkg_dep()]}.
+-spec parse_deps(binary(), list(), rebar_state:t(), list(), integer()) -> {[rebar_app_info:t()], [pkg_dep()]}.
parse_deps(DepsDir, Deps, State, Locks, Level) ->
lists:foldl(fun(Dep, Acc) ->
Name = case Dep of
diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl
index 77e100f..6bc9f53 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)),
@@ -58,7 +67,7 @@ format_error(Reason) ->
info() ->
io_lib:format(
- "Create rebar project based on template and vars.~n"
+ "Create rebar3 project based on template and vars.~n"
"~n"
"Valid command line options:~n"
" template= [var=foo,...]~n", []).
diff --git a/src/rebar_prv_wtf.erl b/src/rebar_prv_wtf.erl
index f876760..9be9a4b 100644
--- a/src/rebar_prv_wtf.erl
+++ b/src/rebar_prv_wtf.erl
@@ -26,8 +26,8 @@ init(State) ->
{bare, false},
{deps, ?DEPS},
{example, "rebar3 wtf \"<task>\""},
- {short_desc, "Provide a crash report to be sent to the rebar3 issues page"},
- {desc, "Provide a crash report to be sent to the rebar3 issues page"},
+ {short_desc, "Provide a crash report to be sent to the rebar3 issues page."},
+ {desc, "Provide a crash report to be sent to the rebar3 issues page."},
{opts, [
{task, undefined, undefined, string, "Task to print details for."}
]}])),
diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl
index cc33f51..67cd554 100644
--- a/src/rebar_prv_xref.erl
+++ b/src/rebar_prv_xref.erl
@@ -66,7 +66,7 @@ format_error(Reason) ->
%% ===================================================================
short_desc() ->
- "Run cross reference analysis".
+ "Run cross reference analysis.".
desc() ->
io_lib:format(
@@ -88,7 +88,7 @@ desc() ->
" - (\"mod\":\".*foo\"/\"4\"))",[]}]}
]).
--spec prepare(rebar_state:t()) -> list(atom()).
+-spec prepare(rebar_state:t()) -> {[file:filename()], [atom()]}.
prepare(State) ->
{ok, _} = xref:start(xref),
ok = xref:set_library_path(xref, code_path(State)),
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index c4cb94d..cd127c0 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -41,7 +41,7 @@
lock = [],
current_profiles = [default] :: [atom()],
- namespace = undefined :: [atom()],
+ namespace = undefined :: atom(),
command_args = [],
command_parsed_args = [],
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index df25997..d92ab80 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -49,7 +49,10 @@
erl_opts/1,
indent/1,
cleanup_code_path/1,
- args_to_tasks/1]).
+ args_to_tasks/1,
+ expand_env_variable/3,
+ get_arch/0,
+ wordsize/0]).
%% for internal use only
-export([otp_release/0]).