From 1f077009307b84051a8406bc8ca33def0852ea33 Mon Sep 17 00:00:00 2001 From: terry-xiaoyu <506895667@qq.com> Date: Sat, 16 May 2020 08:48:05 +0800 Subject: [PATCH] Print helpful messages when no commands available --- src/emqx_ctl.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index 4b6c375d1..d42862fc1 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -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) ->