allow to override command

This commit is contained in:
Feng 2015-10-10 19:47:38 +08:00
parent b59a8664eb
commit aad1f3547f
1 changed files with 7 additions and 1 deletions

View File

@ -110,7 +110,13 @@ handle_call(_Request, _From, State) ->
{reply, ok, State}. {reply, ok, State}.
handle_cast({register_cmd, Cmd, MF, Opts}, State = #state{seq = Seq}) -> handle_cast({register_cmd, Cmd, MF, Opts}, State = #state{seq = Seq}) ->
ets:insert(?CMD_TAB, {{Seq, Cmd}, MF, Opts}), case ets:match(?CMD_TAB, {{'$1', Cmd}, '_', '_'}) of
[] ->
ets:insert(?CMD_TAB, {{Seq, Cmd}, MF, Opts});
[[OriginSeq] | _] ->
lager:error("CLI: ~s is overidden by ~p", [Cmd, MF]),
ets:insert(?CMD_TAB, {{OriginSeq, Cmd}, MF, Opts})
end,
noreply(next_seq(State)); noreply(next_seq(State));
handle_cast({unregister_cmd, Cmd}, State) -> handle_cast({unregister_cmd, Cmd}, State) ->