Просмотр исходного кода

feat(emqx_ctl): support hidden commands

hidden commands do not deserve a place in the usage page
Zaiming (Stone) Shi 2 лет назад
Родитель
Сommit
96a41ac6bd
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      apps/emqx_ctl/src/emqx_ctl.erl

+ 10 - 7
apps/emqx_ctl/src/emqx_ctl.erl

@@ -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, [])]).