From ba79fc082334574f4ff0f543615e041cbd1d6a17 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Fri, 6 Mar 2015 21:43:36 -0800 Subject: parse `rebar3 as foo, bar task` correctly fixes #238 --- src/rebar_prv_as.erl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_as.erl b/src/rebar_prv_as.erl index 7ac5465..beee00d 100644 --- a/src/rebar_prv_as.erl +++ b/src/rebar_prv_as.erl @@ -51,19 +51,23 @@ args_to_profiles_and_tasks(Args) -> first_profile([]) -> {[], []}; first_profile([ProfileList|Rest]) -> case re:split(ProfileList, ",", [{return, list}, {parts, 2}]) of - %% profile terminated by comma - [P, More] -> profiles([More] ++ Rest, [P]); - %% profile not terminated by comma - [P] -> comma_or_end(Rest, [P]) + %% `foo, bar` + [P, ""] -> profiles(Rest, [P]); + %% `foo,bar` + [P, More] -> profiles([More] ++ Rest, [P]); + %% `foo` + [P] -> comma_or_end(Rest, [P]) end. profiles([], Acc) -> {lists:reverse(Acc), rebar_utils:args_to_tasks([])}; profiles([ProfileList|Rest], Acc) -> case re:split(ProfileList, ",", [{return, list}, {parts, 2}]) of - %% profile terminated by comma - [P, More] -> profiles([More] ++ Rest, [P|Acc]); - %% profile not terminated by comma - [P] -> comma_or_end(Rest, [P|Acc]) + %% `foo, bar` + [P, ""] -> profiles(Rest, [P|Acc]); + %% `foo,bar` + [P, More] -> profiles([More] ++ Rest, [P|Acc]); + %% `foo` + [P] -> comma_or_end(Rest, [P|Acc]) end. %% `, foo...` -- cgit v1.1