Thales Macedo Garitezi 19f3b030f9 chore: preparing to run common tests / eunit with mix hai 1 ano
..
src 46877e979b chore: update copyright-year hai 1 ano
test 46877e979b chore: update copyright-year hai 1 ano
README.md c739d9957c docs: add readme for emqx_ctl app %!s(int64=2) %!d(string=hai) anos
mix.exs 19f3b030f9 chore: preparing to run common tests / eunit with mix hai 1 ano
rebar.config 5e100f52b8 style: erlfmt all `rebar.config` files and `bin/nodetool` %!s(int64=2) %!d(string=hai) anos

README.md

emqx_ctl

This application accepts dynamic emqx ctl command registrations so plugins can add their own commands. Please note that the 'proxy' command emqx_ctl is considered deprecated, going forward, please use emqx ctl instead.

Add a new command

To add a new command, the application must implement a callback function to handle the command, and register the command with emqx_ctl:register_command/2 API.

Register

To add a new command which can be executed from emqx ctl, the application must call emqx_ctl:register_command/2 API to register the command.

For example, to add a new command myplugin which is to be executed as emqx ctl myplugin, the application must call emqx_ctl:register_command/2 API as follows:

emqx_ctl:register_command(mypluin, {myplugin_cli, cmd}).

Callback

The callback function must be exported by the application and must have the following signature:

cmd([Arg1, Arg2, ...]) -> ok.

It must also implement a special clause to handle the usage argument:

cmd([usage]) -> "myplugin [arg1] [arg2] ...";

Utility

The emqx_ctl application provides some utility functions which help to format the output of the command. For example emqx_ctl:print/2 and emqx_ctl:usage/1.

Reference

emqx_management_cli can be taken as a reference for how to implement a command.