summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-03-23 17:49:07 +0300
committerMichael Klishin <mklishin@pivotal.io>2016-03-24 21:49:15 +0300
commitd19bf82d3fcebc80b0007e63493d37196f8f3c87 (patch)
tree7ed12432038c80212c2a3b96cc3bbedcd88238a8 /src
parent4aa2aa0d8d975f1531289ae9e7b1f419f9a8a0b2 (diff)
downloadrabbitmq-server-git-d19bf82d3fcebc80b0007e63493d37196f8f3c87.tar.gz
Fix `rabbitmqctl list_consumers`
As we are mapping over queues in search of their consumers, actual result for every queue could be zero or more consumers. We need to take that into account while printing. Closes #701
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_control_main.erl27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index b805d21e48..ded52d2c00 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -753,15 +753,26 @@ default_if_empty(List, Default) when is_list(List) ->
true -> [list_to_atom(X) || X <- List]
end.
+display_info_message_row(IsEscaped, Result, InfoItemKeys) ->
+ display_row([format_info_item(
+ case proplists:lookup(X, Result) of
+ none when is_list(Result), length(Result) > 0 ->
+ exit({error, {bad_info_key, X}});
+ none -> Result;
+ {X, Value} -> Value
+ end, IsEscaped) || X <- InfoItemKeys]).
+
display_info_message(IsEscaped) ->
- fun(Result, InfoItemKeys) ->
- display_row([format_info_item(
- case proplists:lookup(X, Result) of
- none when is_list(Result), length(Result) > 0 ->
- exit({error, {bad_info_key, X}});
- none -> Result;
- {X, Value} -> Value
- end, IsEscaped) || X <- InfoItemKeys])
+ fun ([], _) ->
+ ok;
+ ([FirstResult|_] = List, InfoItemKeys) when is_list(FirstResult) ->
+ lists:foreach(fun(Result) ->
+ display_info_message_row(IsEscaped, Result, InfoItemKeys)
+ end,
+ List),
+ ok;
+ (Result, InfoItemKeys) ->
+ display_info_message_row(IsEscaped, Result, InfoItemKeys)
end.
display_info_list(Results, InfoItemKeys) when is_list(Results) ->