feat(emqx_ctl): support hidden commands

hidden commands do not deserve a place in the usage page
This commit is contained in:
Zaiming (Stone) Shi 2023-06-08 17:10:49 +02:00 committed by zhongwencool
parent 47f826f99a
commit 96a41ac6bd
1 changed files with 10 additions and 7 deletions

View File

@ -157,18 +157,21 @@ help() ->
print("No commands available.~n");
Cmds ->
print("Usage: ~ts~n", ["emqx ctl"]),
lists:foreach(
fun({_, {Mod, Cmd}, _}) ->
print("~110..-s~n", [""]),
apply(Mod, Cmd, [usage])
end,
Cmds
)
lists:foreach(fun print_usage/1, Cmds)
end;
false ->
print("Command table is initializing.~n")
end.
print_usage({_, {Mod, Cmd}, Opts}) ->
case proplists:get_bool(hidden, Opts) of
true ->
ok;
false ->
print("~110..-s~n", [""]),
apply(Mod, Cmd, [usage])
end.
-spec print(io:format()) -> ok.
print(Msg) ->
io:format("~ts", [format(Msg, [])]).