diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-22 18:22:24 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-22 18:22:24 +0100 |
| commit | c4caae36bdb0179211d1aa6c665bc5466c74f563 (patch) | |
| tree | 1be66f9128a3d5e4517b9fe05058f9d8be7f3052 | |
| parent | 4b27b8f67ac821d797924e39029176b6ea82f700 (diff) | |
| download | rabbitmq-server-git-c4caae36bdb0179211d1aa6c665bc5466c74f563.tar.gz | |
Simon's readability patch
| -rw-r--r-- | src/rabbit_plugins.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index b93b7bed99..b5bcf8200d 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]), |
