Pārlūkot izejas kodu

fix(cli): subscriptions with sub options, qos rh rap nl; admins response
data format

DDDHuang 3 gadi atpakaļ
vecāks
revīzija
941440800b

+ 1 - 1
apps/emqx_dashboard/src/emqx_dashboard.app.src

@@ -2,7 +2,7 @@
 {application, emqx_dashboard, [
     {description, "EMQX Web Dashboard"},
     % strict semver, bump manually!
-    {vsn, "5.0.2"},
+    {vsn, "5.0.3"},
     {modules, []},
     {registered, [emqx_dashboard_sup]},
     {applications, [kernel, stdlib, mnesia, minirest, emqx]},

+ 19 - 5
apps/emqx_dashboard/src/emqx_dashboard_cli.erl

@@ -32,14 +32,22 @@ admins(["add", Username, Password, Desc]) ->
         {ok, _} ->
             emqx_ctl:print("ok~n");
         {error, Reason} ->
-            emqx_ctl:print("Error: ~p~n", [Reason])
+            print_error(Reason)
     end;
 admins(["passwd", Username, Password]) ->
-    Status = emqx_dashboard_admin:change_password(bin(Username), bin(Password)),
-    emqx_ctl:print("~p~n", [Status]);
+    case emqx_dashboard_admin:change_password(bin(Username), bin(Password)) of
+        {ok, _} ->
+            emqx_ctl:print("ok~n");
+        {error, Reason} ->
+            print_error(Reason)
+    end;
 admins(["del", Username]) ->
-    Status = emqx_dashboard_admin:remove_user(bin(Username)),
-    emqx_ctl:print("~p~n", [Status]);
+    case emqx_dashboard_admin:remove_user(bin(Username)) of
+        {ok, _} ->
+            emqx_ctl:print("ok~n");
+        {error, Reason} ->
+            print_error(Reason)
+    end;
 admins(_) ->
     emqx_ctl:usage(
         [
@@ -53,3 +61,9 @@ unload() ->
     emqx_ctl:unregister_command(admins).
 
 bin(S) -> iolist_to_binary(S).
+
+print_error(Reason) when is_binary(Reason) ->
+    emqx_ctl:print("Error: ~s~n", [Reason]).
+%% Maybe has more types of error, but there is only binary now. So close it for dialyzer.
+% print_error(Reason) ->
+%     emqx_ctl:print("Error: ~p~n", [Reason]).

+ 1 - 1
apps/emqx_management/src/emqx_management.app.src

@@ -2,7 +2,7 @@
 {application, emqx_management, [
     {description, "EMQX Management API and CLI"},
     % strict semver, bump manually!
-    {vsn, "5.0.1"},
+    {vsn, "5.0.2"},
     {modules, []},
     {registered, [emqx_management_sup]},
     {applications, [kernel, stdlib, emqx_plugins, minirest, emqx]},

+ 6 - 1
apps/emqx_management/src/emqx_mgmt_cli.erl

@@ -780,7 +780,12 @@ print({emqx_topic, #route{topic = Topic, dest = {_, Node}}}) ->
 print({emqx_topic, #route{topic = Topic, dest = Node}}) ->
     emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
 print({emqx_suboption, {{Pid, Topic}, Options}}) when is_pid(Pid) ->
-    emqx_ctl:print("~ts -> ~ts~n", [maps:get(subid, Options), Topic]).
+    SubId = maps:get(subid, Options),
+    QoS = maps:get(qos, Options, 0),
+    NL = maps:get(nl, Options, 0),
+    RH = maps:get(rh, Options, 0),
+    RAP = maps:get(rap, Options, 0),
+    emqx_ctl:print("~ts -> topic:~ts qos:~p nl:~p rh:~p rap:~p~n", [SubId, Topic, QoS, NL, RH, RAP]).
 
 format(_, undefined) ->
     undefined;