summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-22 18:22:24 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-22 18:22:24 +0100
commit693517dd96c02697414c04cedb45ca9fd932138c (patch)
tree1be66f9128a3d5e4517b9fe05058f9d8be7f3052
parentbb3785515ef0fccd158b81ddd2ee3b5df8b538c6 (diff)
downloadrabbitmq-server-693517dd96c02697414c04cedb45ca9fd932138c.tar.gz
Simon's readability patch
-rw-r--r--src/rabbit_plugins.erl17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index b93b7bed..b5bcf820 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -208,23 +208,28 @@ format_plugins(Pattern, Compact) ->
calculate_required_plugins(EnabledExplicitly, AvailablePlugins) --
EnabledExplicitly,
{ok, RE} = re:compile(Pattern),
- [ format_plugin(P, EnabledExplicitly, EnabledImplicitly, Compact)
- || P = #plugin{name = Name} <- AvailablePlugins,
- re:run(atom_to_list(Name), RE, [{capture, none}]) =:= match],
+ Plugins = [ Plugin ||
+ Plugin = #plugin{name = Name} <- AvailablePlugins,
+ re:run(atom_to_list(Name), RE, [{capture, none}]) =:= match],
+ MaxWidth = lists:max([length(atom_to_list(Name)) ||
+ #plugin{name = Name} <- Plugins]),
+ [ format_plugin(P, EnabledExplicitly, EnabledImplicitly, Compact, MaxWidth) ||
+ P <- Plugins],
ok.
format_plugin(#plugin{name = Name, version = Version, description = Description,
dependencies = Dependencies},
- EnabledExplicitly, EnabledImplicitly, Compact) ->
+ EnabledExplicitly, EnabledImplicitly, Compact, MaxWidth) ->
Glyph = case {lists:member(Name, EnabledExplicitly),
lists:member(Name, EnabledImplicitly)} of
{true, false} -> "[E]";
{false, true} -> "[e]";
- _ -> "[A]"
+ _ -> "[ ]"
end,
case Compact of
true ->
- io:format("~s ~w-~s: ~s~n", [Glyph, Name, Version, Description]);
+ io:format("~s ~-" ++ integer_to_list(MaxWidth) ++
+ "w ~s~n", [Glyph, Name, Version]);
false ->
io:format("~s ~w~n", [Glyph, Name]),
io:format(" Version: \t~s~n", [Version]),