Skip to content

Commit

Permalink
Merge pull request #115 from emqx/rebar3-plugin
Browse files Browse the repository at this point in the history
fix cli demo
  • Loading branch information
sstrigler authored Jun 19, 2023
2 parents 0b2cc6a + 60fc6e3 commit d2f31c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion emqx-plugin.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
{file, "erlang_ls.config", "{{name}}/erlang_ls.config"}.
{file, "get-rebar3", "{{name}}/get-rebar3"}.
{file, "priv/config.hocon", "{{name}}/priv/config.hocon"}.
{file, "src/emqx_cli_demo.erl", "{{name}}/src/emqx_cli_demo.erl"}.
{chmod, "{{name}}/get-rebar3", 8#755}.
{template, "README_template.md", "{{name}}/README.md"}.
{template, "rebar_template.config", "{{name}}/rebar.config"}.
{template, "src/emqx_plugin_template.app.src", "{{name}}/src/{{name}}.app.src"}.
{template, "src/emqx_plugin_template.erl", "{{name}}/src/{{name}}.erl"}.
{template, "src/emqx_plugin_template_app.erl", "{{name}}/src/{{name}}_app.erl"}.
{template, "src/emqx_plugin_template_cli.erl", "{{name}}/src/{{name}}_cli.erl"}.
{template, "src/emqx_plugin_template_sup.erl", "{{name}}/src/{{name}}_sup.erl"}.
27 changes: 0 additions & 27 deletions src/emqx_cli_demo.erl

This file was deleted.

3 changes: 3 additions & 0 deletions src/emqx_plugin_template_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
start(_StartType, _StartArgs) ->
{ok, Sup} = @@name@@_sup:start_link(),
@@name@@:load(application:get_all_env()),

emqx_ctl:register_command(@@name@@, {@@name@@_cli, cmd}),
{ok, Sup}.

stop(_State) ->
emqx_ctl:unregister_command(@@name@@),
@@name@@:unload().
12 changes: 12 additions & 0 deletions src/emqx_plugin_template_cli.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{=@@ @@=}}
-module(@@name@@_cli).

%% This is an example on how to extend `emqx ctl` with your own commands.

-export([cmd/1]).

cmd(["arg1", "arg2"]) ->
emqx_ctl:print("ok");

cmd(_) ->
emqx_ctl:usage([{"cmd arg1 arg2", "cmd demo"}]).

0 comments on commit d2f31c4

Please sign in to comment.