Merge pull request #1134 from emqtt/develop
Fix exit code of emqttd_ctl CLI
This commit is contained in:
commit
3d284c9313
|
@ -64,14 +64,22 @@ cast(Msg) -> gen_server:cast(?SERVER, Msg).
|
||||||
|
|
||||||
%% @doc Run a command
|
%% @doc Run a command
|
||||||
-spec(run([string()]) -> any()).
|
-spec(run([string()]) -> any()).
|
||||||
run([]) -> usage();
|
run([]) -> usage(), ok;
|
||||||
|
|
||||||
run(["help"]) -> usage();
|
run(["help"]) -> usage(), ok;
|
||||||
|
|
||||||
run([CmdS|Args]) ->
|
run([CmdS|Args]) ->
|
||||||
case lookup(list_to_atom(CmdS)) of
|
case lookup(list_to_atom(CmdS)) of
|
||||||
[{Mod, Fun}] -> Mod:Fun(Args);
|
[{Mod, Fun}] ->
|
||||||
[] -> usage()
|
try Mod:Fun(Args) of
|
||||||
|
_ -> ok
|
||||||
|
catch
|
||||||
|
_:Reason ->
|
||||||
|
{error, Reason}
|
||||||
|
end;
|
||||||
|
[] ->
|
||||||
|
usage(),
|
||||||
|
{error, cmd_not_found}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Lookup a command
|
%% @doc Lookup a command
|
||||||
|
|
Loading…
Reference in New Issue