summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_prv_new.erl6
-rw-r--r--test/rebar_new_SUITE.erl39
2 files changed, 43 insertions, 2 deletions
diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl
index 6574aca..28572a9 100644
--- a/src/rebar_prv_new.erl
+++ b/src/rebar_prv_new.erl
@@ -32,7 +32,7 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
- case rebar_state:command_args(State) of
+ case strip_flags(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)),
@@ -72,6 +72,10 @@ info() ->
"Valid command line options:~n"
" <template> [var=foo,...]~n", []).
+strip_flags([]) -> [];
+strip_flags(["-"++_|Opts]) -> strip_flags(Opts);
+strip_flags([Opt | Opts]) -> [Opt | strip_flags(Opts)].
+
is_forced(State) ->
{Args, _} = rebar_state:command_parsed_args(State),
case proplists:get_value(force, Args) of
diff --git a/test/rebar_new_SUITE.erl b/test/rebar_new_SUITE.erl
index 3cee6f2..b514a2b 100644
--- a/test/rebar_new_SUITE.erl
+++ b/test/rebar_new_SUITE.erl
@@ -6,7 +6,8 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-all() -> [app_git_user, app_hg_user, app_with_fallbacks].
+all() -> [app_git_user, app_hg_user, app_with_fallbacks,
+ app_with_flags1, app_with_flags2].
init_per_testcase(Case, Config0) ->
@@ -95,6 +96,42 @@ app_hg_user(Config) ->
{filename:join(["src", Name++"_app.erl"]), [Name]}
]).
+app_with_flags1(Config) ->
+ Name = ?config(name, Config),
+ rebar_test_utils:run_and_check(
+ Config, [],
+ ["new", "test_app", "-f", Name],
+ {ok, []}
+ ),
+ validate_files(
+ Config, Name,
+ [{"LICENSE", []},
+ {"README.md", []},
+ {".gitignore", []},
+ {"rebar.config", []},
+ {filename:join(["src", Name++".app.src"]), [Name]},
+ {filename:join(["src", Name++"_sup.erl"]), [Name]},
+ {filename:join(["src", Name++"_app.erl"]), [Name]}
+ ]).
+
+app_with_flags2(Config) ->
+ Name = ?config(name, Config),
+ rebar_test_utils:run_and_check(
+ Config, [],
+ ["new", "-f", "test_app", Name],
+ {ok, []}
+ ),
+ validate_files(
+ Config, Name,
+ [{"LICENSE", []},
+ {"README.md", []},
+ {".gitignore", []},
+ {"rebar.config", []},
+ {filename:join(["src", Name++".app.src"]), [Name]},
+ {filename:join(["src", Name++"_sup.erl"]), [Name]},
+ {filename:join(["src", Name++"_app.erl"]), [Name]}
+ ]).
+
validate_files(_Config, Name, Checks) ->
[begin
Path = filename:join([Name, File]),