fix: format the outputs for rule engine CLIs

This commit is contained in:
Shawn 2022-06-17 18:09:22 +08:00
parent 6685a3c5a8
commit f132b6f6ae
2 changed files with 13 additions and 4 deletions

View File

@ -25,6 +25,8 @@
-import(hoconsc, [mk/2, ref/2, array/1]).
-export([printable_function_name/2]).
%% Swagger specs from hocon schema
-export([api_spec/0, paths/0, schema/1, namespace/0]).

View File

@ -84,10 +84,17 @@ pretty_print_rule(ID) ->
end.
%% erlfmt-ignore
format_action(#{func := Func, args := Args}) ->
io_lib:format("Function:\n ~p\n"
"Args:\n ~p\n"
,[Func, maps:without([preprocessed_tmpl], Args)]
format_action(#{mod := Mod, func := Func, args := Args}) ->
Name = emqx_rule_engine_api:printable_function_name(Mod, Func),
io_lib:format("- Name: ~s\n"
" Type: function\n"
" Args: ~p\n"
,[Name, maps:without([preprocessed_tmpl], Args)]
);
format_action(BridgeChannelId) when is_binary(BridgeChannelId) ->
io_lib:format("- Name: ~s\n"
" Type: data-bridge\n"
,[BridgeChannelId]
).
left_pad(Str) ->