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

chore(auth-mnesia): update cli

zhanghongtong пре 5 година
родитељ
комит
7a1993f13b

+ 12 - 3
apps/emqx_auth_mnesia/src/emqx_acl_mnesia_cli.erl

@@ -160,18 +160,27 @@ cli(["show", "username", Username]) ->
     [print_acl(Acl) || Acl <- lookup_acl({username, iolist_to_binary(Username)})];
 
 cli(["del", "clientid", Clientid, Topic])->
+    cli(["delete", "clientid", Clientid, Topic]);
+
+cli(["delete", "clientid", Clientid, Topic])->
     case remove_acl({clientid, iolist_to_binary(Clientid)}, iolist_to_binary(Topic)) of
          ok -> emqx_ctl:print("ok~n");
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
     end;
 
 cli(["del", "username", Username, Topic])->
+    cli(["delete", "username", Username, Topic]);
+
+cli(["delete", "username", Username, Topic])->
     case remove_acl({username, iolist_to_binary(Username)}, iolist_to_binary(Topic)) of
          ok -> emqx_ctl:print("ok~n");
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
     end;
 
 cli(["del", "_all", Topic])->
+    cli(["delete", "_all", Topic]);
+
+cli(["delete", "_all", Topic])->
     case remove_acl(all, iolist_to_binary(Topic)) of
          ok -> emqx_ctl:print("ok~n");
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
@@ -186,9 +195,9 @@ cli(_) ->
                    , {"acl aad clientid <Clientid> <Topic> <Action> <Access>", "Add clientid acl"}
                    , {"acl add Username <Username> <Topic> <Action> <Access>", "Add username acl"}
                    , {"acl add _all <Topic> <Action> <Access>", "Add $all acl"}
-                   , {"acl del clientid <Clientid> <Topic>", "Delete clientid acl"}
-                   , {"acl del username <Username> <Topic>", "Delete username acl"}
-                   , {"acl del _all <Topic>", "Delete $all acl"}
+                   , {"acl delete clientid <Clientid> <Topic>", "Delete clientid acl"}
+                   , {"acl delete username <Username> <Topic>", "Delete username acl"}
+                   , {"acl delete _all <Topic>", "Delete $all acl"}
                    ]).
 
 %%--------------------------------------------------------------------

+ 8 - 2
apps/emqx_auth_mnesia/src/emqx_auth_mnesia_cli.erl

@@ -144,6 +144,9 @@ auth_clientid_cli(["update", ClientId, NewPassword]) ->
     end;
 
 auth_clientid_cli(["del", ClientId]) ->
+    auth_clientid_cli(["delete", ClientId]);
+
+auth_clientid_cli(["delete", ClientId]) ->
     case  remove_user({clientid, iolist_to_binary(ClientId)}) of
         ok -> emqx_ctl:print("ok~n");
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
@@ -153,7 +156,7 @@ auth_clientid_cli(_) ->
     emqx_ctl:usage([{"clientid list", "List clientid auth rules"},
                     {"clientid add <Username> <Password>", "Add clientid auth rule"},
                     {"clientid update <Username> <NewPassword>", "Update clientid auth rule"},
-                    {"clientid del <Username>", "Delete clientid auth rule"}]).
+                    {"clientid delete <Username>", "Delete clientid auth rule"}]).
 
 %%--------------------------------------------------------------------
 %% Auth Username Cli
@@ -176,6 +179,9 @@ auth_username_cli(["update", Username, NewPassword]) ->
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
     end;
 auth_username_cli(["del", Username]) ->
+    auth_username_cli(["delete", Username]);
+
+auth_username_cli(["delete", Username]) ->
     case  remove_user({username, iolist_to_binary(Username)}) of
         ok -> emqx_ctl:print("ok~n");
         {error, Reason} -> emqx_ctl:print("Error: ~p~n", [Reason])
@@ -185,4 +191,4 @@ auth_username_cli(_) ->
     emqx_ctl:usage([{"user list", "List username auth rules"},
                     {"user add <Username> <Password>", "Add username auth rule"},
                     {"user update <Username> <NewPassword>", "Update username auth rule"},
-                    {"user del <Username>", "Delete username auth rule"}]).
+                    {"user delete <Username>", "Delete username auth rule"}]).