Merge pull request #8471 from DDDHuang/fix_ctl_cmd
fix(cli): subscriptions with sub options, qos rh rap nl; admins response data format
This commit is contained in:
commit
472673c5b6
|
@ -2,7 +2,7 @@
|
||||||
{application, emqx_dashboard, [
|
{application, emqx_dashboard, [
|
||||||
{description, "EMQX Web Dashboard"},
|
{description, "EMQX Web Dashboard"},
|
||||||
% strict semver, bump manually!
|
% strict semver, bump manually!
|
||||||
{vsn, "5.0.2"},
|
{vsn, "5.0.3"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_dashboard_sup]},
|
{registered, [emqx_dashboard_sup]},
|
||||||
{applications, [kernel, stdlib, mnesia, minirest, emqx]},
|
{applications, [kernel, stdlib, mnesia, minirest, emqx]},
|
||||||
|
|
|
@ -32,14 +32,22 @@ admins(["add", Username, Password, Desc]) ->
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
emqx_ctl:print("ok~n");
|
emqx_ctl:print("ok~n");
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
emqx_ctl:print("Error: ~p~n", [Reason])
|
print_error(Reason)
|
||||||
end;
|
end;
|
||||||
admins(["passwd", Username, Password]) ->
|
admins(["passwd", Username, Password]) ->
|
||||||
Status = emqx_dashboard_admin:change_password(bin(Username), bin(Password)),
|
case emqx_dashboard_admin:change_password(bin(Username), bin(Password)) of
|
||||||
emqx_ctl:print("~p~n", [Status]);
|
{ok, _} ->
|
||||||
|
emqx_ctl:print("ok~n");
|
||||||
|
{error, Reason} ->
|
||||||
|
print_error(Reason)
|
||||||
|
end;
|
||||||
admins(["del", Username]) ->
|
admins(["del", Username]) ->
|
||||||
Status = emqx_dashboard_admin:remove_user(bin(Username)),
|
case emqx_dashboard_admin:remove_user(bin(Username)) of
|
||||||
emqx_ctl:print("~p~n", [Status]);
|
{ok, _} ->
|
||||||
|
emqx_ctl:print("ok~n");
|
||||||
|
{error, Reason} ->
|
||||||
|
print_error(Reason)
|
||||||
|
end;
|
||||||
admins(_) ->
|
admins(_) ->
|
||||||
emqx_ctl:usage(
|
emqx_ctl:usage(
|
||||||
[
|
[
|
||||||
|
@ -53,3 +61,9 @@ unload() ->
|
||||||
emqx_ctl:unregister_command(admins).
|
emqx_ctl:unregister_command(admins).
|
||||||
|
|
||||||
bin(S) -> iolist_to_binary(S).
|
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]).
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{application, emqx_management, [
|
{application, emqx_management, [
|
||||||
{description, "EMQX Management API and CLI"},
|
{description, "EMQX Management API and CLI"},
|
||||||
% strict semver, bump manually!
|
% strict semver, bump manually!
|
||||||
{vsn, "5.0.1"},
|
{vsn, "5.0.2"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_management_sup]},
|
{registered, [emqx_management_sup]},
|
||||||
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx]},
|
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx]},
|
||||||
|
|
|
@ -780,7 +780,12 @@ print({emqx_topic, #route{topic = Topic, dest = {_, Node}}}) ->
|
||||||
print({emqx_topic, #route{topic = Topic, dest = Node}}) ->
|
print({emqx_topic, #route{topic = Topic, dest = Node}}) ->
|
||||||
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
||||||
print({emqx_suboption, {{Pid, Topic}, Options}}) when is_pid(Pid) ->
|
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) ->
|
format(_, undefined) ->
|
||||||
undefined;
|
undefined;
|
||||||
|
|
Loading…
Reference in New Issue