feat(shell): add emqx version to prompt.
This commit is contained in:
parent
6a701e098f
commit
3efa583830
|
@ -24,6 +24,7 @@
|
|||
|
||||
start(_Type, _Args) ->
|
||||
ok = emqx_machine:start(),
|
||||
emqx_restricted_shell:set_prompt_func(),
|
||||
emqx_machine_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
-module(emqx_restricted_shell).
|
||||
|
||||
-export([local_allowed/3, non_local_allowed/3]).
|
||||
-export([set_prompt_func/0, prompt_func/1]).
|
||||
-export([lock/0, unlock/0, is_locked/0]).
|
||||
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
@ -38,6 +39,17 @@ is_locked() ->
|
|||
lock() -> application:set_env(?APP, ?IS_LOCKED, true).
|
||||
unlock() -> application:set_env(?APP, ?IS_LOCKED, false).
|
||||
|
||||
set_prompt_func() ->
|
||||
shell:prompt_func({?MODULE, prompt_func}).
|
||||
|
||||
prompt_func(PropList) ->
|
||||
Line = proplists:get_value(history, PropList, 1),
|
||||
Version = emqx_release:version(),
|
||||
case is_alive() of
|
||||
true -> io_lib:format(<<"~ts(~s)~w> ">>, [Version, node(), Line]);
|
||||
false -> io_lib:format(<<"~ts ~w> ">>, [Version, Line])
|
||||
end.
|
||||
|
||||
local_allowed(MF, Args, State) ->
|
||||
IsAllowed = is_allowed(MF, ?LOCAL_NOT_ALLOWED),
|
||||
log(IsAllowed, MF, Args),
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx_conf/include/emqx_conf.hrl").
|
||||
-include_lib("emqx_dashboard/include/emqx_dashboard.hrl").
|
||||
-include_lib("emqx_slow_subs/include/emqx_slow_subs.hrl").
|
||||
|
||||
%% API
|
||||
-export([lock/0, unlock/0]).
|
||||
|
|
Loading…
Reference in New Issue