Преглед изворни кода

feat(emqx_ctl): support hidden commands

hidden commands do not deserve a place in the usage page
Zaiming (Stone) Shi пре 2 година
родитељ
комит
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");
                     print("No commands available.~n");
                 Cmds ->
                 Cmds ->
                     print("Usage: ~ts~n", ["emqx ctl"]),
                     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;
             end;
         false ->
         false ->
             print("Command table is initializing.~n")
             print("Command table is initializing.~n")
     end.
     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.
 -spec print(io:format()) -> ok.
 print(Msg) ->
 print(Msg) ->
     io:format("~ts", [format(Msg, [])]).
     io:format("~ts", [format(Msg, [])]).