@@ -25,33 +25,42 @@ init(State) ->
25
25
{deps , ? DEPS },
26
26
{example , " rebar3 plugins upgrade <plugin>" },
27
27
{short_desc , " Upgrade plugins" },
28
- {desc , " List or upgrade plugins" },
28
+ {desc , " List or upgrade plugins. Use the -a/--all option to upgrade"
29
+ " all plugins." },
29
30
{opts , [{plugin , undefined , undefined , string ,
30
- " Plugin to upgrade" }]}])),
31
+ " Plugin to upgrade" },
32
+ {all , $a , " all" , undefined , " Upgrade all plugins." }]}])),
31
33
{ok , State1 }.
32
34
33
35
-spec do (rebar_state :t ()) -> {ok , rebar_state :t ()} | {error , string ()}.
34
36
do (State ) ->
35
- { Args , _ } = rebar_state : command_parsed_args (State ),
36
- case proplists : get_value ( plugin , Args , none ) of
37
- none ->
37
+ case handle_args (State ) of
38
+ { false , undefined } -> throw ( ? PRV_ERROR ( no_arg ));
39
+ { true , _ } ->
38
40
{_ , LocalPluginsNames } = rebar_prv_plugins :list_local_plugins (State ),
39
41
lists :foldl (
40
42
fun (LocalPluginName , {ok , StateAcc }) ->
41
43
upgrade (atom_to_list (LocalPluginName ), StateAcc )
42
44
end ,
43
45
{ok , State },
44
46
LocalPluginsNames );
45
- Plugin ->
46
- upgrade (Plugin , State )
47
+ {false , Plugin } -> upgrade (Plugin , State )
47
48
end .
48
49
49
50
-spec format_error (any ()) -> iolist ().
50
51
format_error ({not_found , Plugin }) ->
51
52
io_lib :format (" Plugin to upgrade not found: ~ts " , [Plugin ]);
53
+ format_error (no_arg ) ->
54
+ " Specify a plugin to upgrade, or --all to upgrade them all" ;
52
55
format_error (Reason ) ->
53
56
io_lib :format (" ~p " , [Reason ]).
54
57
58
+ handle_args (State ) ->
59
+ {Args , _ } = rebar_state :command_parsed_args (State ),
60
+ All = proplists :get_value (all , Args , false ),
61
+ Plugin = proplists :get_value (plugin , Args ),
62
+ {All , Plugin }.
63
+
55
64
upgrade (Plugin , State ) ->
56
65
Profiles = rebar_state :current_profiles (State ),
57
66
case find_plugin (Plugin , Profiles , State ) of
0 commit comments