Merge pull request #1134 from emqtt/develop

Fix exit code of emqttd_ctl CLI
This commit is contained in:
Feng Lee 2017-07-06 12:34:34 +08:00 committed by GitHub
commit 3d284c9313
1 changed files with 12 additions and 4 deletions

View File

@ -64,14 +64,22 @@ cast(Msg) -> gen_server:cast(?SERVER, Msg).
%% @doc Run a command
-spec(run([string()]) -> any()).
run([]) -> usage();
run([]) -> usage(), ok;
run(["help"]) -> usage();
run(["help"]) -> usage(), ok;
run([CmdS|Args]) ->
case lookup(list_to_atom(CmdS)) of
[{Mod, Fun}] -> Mod:Fun(Args);
[] -> usage()
[{Mod, Fun}] ->
try Mod:Fun(Args) of
_ -> ok
catch
_:Reason ->
{error, Reason}
end;
[] ->
usage(),
{error, cmd_not_found}
end.
%% @doc Lookup a command