mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Fix Dialyzer errors in ejabberd_ctl
This commit is contained in:
parent
1a6c162371
commit
89f99c4251
@ -268,10 +268,8 @@ try_run_ctp(Args, Auth, AccessCommands) ->
|
|||||||
%% @spec (Args::[string()], Auth, AccessCommands) -> string() | integer() | {string(), integer()}
|
%% @spec (Args::[string()], Auth, AccessCommands) -> string() | integer() | {string(), integer()}
|
||||||
try_call_command(Args, Auth, AccessCommands) ->
|
try_call_command(Args, Auth, AccessCommands) ->
|
||||||
try call_command(Args, Auth, AccessCommands) of
|
try call_command(Args, Auth, AccessCommands) of
|
||||||
{error, command_unknown} ->
|
{error, String} ->
|
||||||
{io_lib:format("Error: command ~p not known.", [hd(Args)]), ?STATUS_ERROR};
|
{String, ?STATUS_ERROR};
|
||||||
{error, wrong_number_parameters} ->
|
|
||||||
{"Error: wrong number of parameters", ?STATUS_ERROR};
|
|
||||||
Res ->
|
Res ->
|
||||||
Res
|
Res
|
||||||
catch
|
catch
|
||||||
@ -280,13 +278,13 @@ try_call_command(Args, Auth, AccessCommands) ->
|
|||||||
{io_lib:format("Problem '~p ~p' occurred executing the command.~nStacktrace: ~p", [A, Why, Stack]), ?STATUS_ERROR}
|
{io_lib:format("Problem '~p ~p' occurred executing the command.~nStacktrace: ~p", [A, Why, Stack]), ?STATUS_ERROR}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Args::[string()], Auth, AccessCommands) -> string() | integer() | {string(), integer()} | {error, ErrorType}
|
%% @spec (Args::[string()], Auth, AccessCommands) -> string() | integer() | {string(), integer()} | {error, string()}
|
||||||
call_command([CmdString | Args], Auth, AccessCommands) ->
|
call_command([CmdString | Args], Auth, AccessCommands) ->
|
||||||
CmdStringU = re:replace(CmdString, "-", "_", [global,{return,list}]),
|
CmdStringU = re:replace(CmdString, "-", "_", [global,{return,list}]),
|
||||||
Command = list_to_atom(CmdStringU),
|
Command = list_to_atom(CmdStringU),
|
||||||
case ejabberd_commands:get_command_format(Command) of
|
case ejabberd_commands:get_command_format(Command) of
|
||||||
{error, command_unknown} ->
|
{error, command_unknown} ->
|
||||||
{error, command_unknown};
|
{error, io_lib:format("Error: command ~p not known.", [hd(Args)])};
|
||||||
{ArgsFormat, ResultFormat} ->
|
{ArgsFormat, ResultFormat} ->
|
||||||
case (catch format_args(Args, ArgsFormat)) of
|
case (catch format_args(Args, ArgsFormat)) of
|
||||||
ArgsFormatted when is_list(ArgsFormatted) ->
|
ArgsFormatted when is_list(ArgsFormatted) ->
|
||||||
@ -299,9 +297,8 @@ call_command([CmdString | Args], Auth, AccessCommands) ->
|
|||||||
{L1, L2} when L1 < L2 -> {L2-L1, "less argument"};
|
{L1, L2} when L1 < L2 -> {L2-L1, "less argument"};
|
||||||
{L1, L2} when L1 > L2 -> {L1-L2, "more argument"}
|
{L1, L2} when L1 > L2 -> {L1-L2, "more argument"}
|
||||||
end,
|
end,
|
||||||
{io_lib:format("Error: the command ~p requires ~p ~s.",
|
{error, io_lib:format("Error: the command ~p requires ~p ~s.",
|
||||||
[CmdString, NumCompa, TextCompa]),
|
[CmdString, NumCompa, TextCompa])}
|
||||||
wrong_command_arguments}
|
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -615,26 +612,26 @@ print_usage_tags(Tag, MaxC, ShCode) ->
|
|||||||
|
|
||||||
print_usage_help(MaxC, ShCode) ->
|
print_usage_help(MaxC, ShCode) ->
|
||||||
LongDesc =
|
LongDesc =
|
||||||
["The special 'help' ejabberdctl command provides help of ejabberd commands.\n\n"
|
"The special 'help' ejabberdctl command provides help of ejabberd commands.\n\n"
|
||||||
"The format is:\n ", ?B("ejabberdctl"), " ", ?B("help"), " [", ?B("--tags"), " ", ?U("[tag]"), " | ", ?U("com?*"), "]\n\n"
|
"The format is:\n "++?B("ejabberdctl")++" "++?B("help")++" ["++?B("--tags")++" "++?U("[tag]")++" | "++?U("com?*")++"]\n\n"
|
||||||
"The optional arguments:\n"
|
"The optional arguments:\n"
|
||||||
" ",?B("--tags")," Show all tags and the names of commands in each tag\n"
|
" "++?B("--tags")++" Show all tags and the names of commands in each tag\n"
|
||||||
" ",?B("--tags"), " ", ?U("tag")," Show description of commands in this tag\n"
|
" "++?B("--tags")++" "++?U("tag")++" Show description of commands in this tag\n"
|
||||||
" ",?U("command")," Show detailed description of the command\n"
|
" "++?U("command")++" Show detailed description of the command\n"
|
||||||
" ",?U("com?*")," Show detailed description of commands that match this glob.\n"
|
" "++?U("com?*")++" Show detailed description of commands that match this glob.\n"
|
||||||
" You can use ? to match a simple character,\n"
|
" You can use ? to match a simple character,\n"
|
||||||
" and * to match several characters.\n"
|
" and * to match several characters.\n"
|
||||||
"\n",
|
"\n"
|
||||||
"Some example usages:\n",
|
"Some example usages:\n"
|
||||||
" ejabberdctl help\n",
|
" ejabberdctl help\n"
|
||||||
" ejabberdctl help --tags\n",
|
" ejabberdctl help --tags\n"
|
||||||
" ejabberdctl help --tags accounts\n",
|
" ejabberdctl help --tags accounts\n"
|
||||||
" ejabberdctl help register\n",
|
" ejabberdctl help register\n"
|
||||||
" ejabberdctl help regist*\n",
|
" ejabberdctl help regist*\n"
|
||||||
"\n",
|
"\n"
|
||||||
"Please note that 'ejabberdctl help' shows all ejabberd commands,\n",
|
"Please note that 'ejabberdctl help' shows all ejabberd commands,\n"
|
||||||
"even those that cannot be used in the shell with ejabberdctl.\n",
|
"even those that cannot be used in the shell with ejabberdctl.\n"
|
||||||
"Those commands can be identified because the description starts with: *"],
|
"Those commands can be identified because the description starts with: *",
|
||||||
ArgsDef = [],
|
ArgsDef = [],
|
||||||
C = #ejabberd_commands{
|
C = #ejabberd_commands{
|
||||||
desc = "Show help of ejabberd commands",
|
desc = "Show help of ejabberd commands",
|
||||||
@ -701,6 +698,7 @@ print_usage_command(Cmd, MaxC, ShCode) ->
|
|||||||
print_usage_command(Cmd, C, MaxC, ShCode)
|
print_usage_command(Cmd, C, MaxC, ShCode)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% @spec (Cmd::string(), C::ejabberd_commands(), MaxC::integer(), ShCode::boolean()) -> ok
|
||||||
print_usage_command(Cmd, C, MaxC, ShCode) ->
|
print_usage_command(Cmd, C, MaxC, ShCode) ->
|
||||||
#ejabberd_commands{
|
#ejabberd_commands{
|
||||||
tags = TagsAtoms,
|
tags = TagsAtoms,
|
||||||
|
Loading…
Reference in New Issue
Block a user