Print helpful messages when no commands available

This commit is contained in:
terry-xiaoyu 2020-05-16 08:48:05 +08:00
parent 80e2bd19b9
commit 1f07700930
1 changed files with 9 additions and 3 deletions

View File

@ -125,9 +125,15 @@ get_commands() ->
[{Cmd, M, F} || {{_Seq, Cmd}, {M, F}, _Opts} <- ets:tab2list(?CMD_TAB)].
help() ->
print("Usage: ~s~n", [?MODULE]),
[begin print("~110..-s~n", [""]), Mod:Cmd(usage) end
|| {_, {Mod, Cmd}, _} <- ets:tab2list(?CMD_TAB)].
case ets:tab2list(?CMD_TAB) of
[] ->
print("No commands available, make sure you have plugin emqx_management started.~n");
Cmds ->
print("Usage: ~s~n", [?MODULE]),
list:foreach(fun({_, {Mod, Cmd}, _}) ->
print("~110..-s~n", [""]), Mod:Cmd(usage)
end, Cmds)
end.
-spec(print(io:format()) -> ok).
print(Msg) ->