@@ -18,17 +18,20 @@ defmodule RabbitMQCtl do
1818 alias RabbitMQ.CLI . { CommandBehaviour , FormatterBehaviour }
1919 alias RabbitMQ.CLI.Ctl.Commands.HelpCommand
2020
21+ @ dialyzer [
22+ { :no_unused , normalise_options: 1 } ,
23+ { :no_unused , normalise_timeout: 1 } ,
24+ { :nowarn_function , output_device: 1 } ,
25+ { :nowarn_function , handle_shutdown: 1 }
26+ ]
27+
2128 # Enable unit tests for private functions
2229 @ compile if Mix . env ( ) == :test , do: :export_all
2330
2431 @ type options ( ) :: map ( )
2532 @ type command_result ( ) :: { :error , ExitCodes . exit_code ( ) , term ( ) } | term ( )
2633
27- @ spec main ( list ( string ( ) ) ) :: no_return ( )
28- def main ( [ "--auto-complete" | [ ] ] ) do
29- handle_shutdown ( :ok )
30- end
31-
34+ @ spec main ( list ( ) ) :: no_return ( )
3235 def main ( unparsed_command ) do
3336 exec_command ( unparsed_command , & process_output / 3 )
3437 |> handle_shutdown
@@ -50,14 +53,13 @@ defmodule RabbitMQCtl do
5053 { :ok , ExitCodes . exit_ok ( ) , Enum . join ( HelpCommand . all_usage ( parsed_options ) , "" ) }
5154 end
5255
53- def exec_command ( [ "--version" ] = _unparsed_command , opts ) do
56+ def exec_command ( [ "--version" ] = _unparsed_command , output_fun ) do
5457 # rewrite `--version` as `version`
55- exec_command ( [ "version" ] , opts )
58+ exec_command ( [ "version" ] , output_fun )
5659 end
5760
58- def exec_command ( [ "--auto-complete" | args ] , opts ) do
59- # rewrite `--auto-complete` as `autocomplete`
60- exec_command ( [ "autocomplete" | args ] , opts )
61+ def exec_command ( [ "--auto-complete" | args ] , output_fun ) do
62+ { :ok , ExitCodes . exit_ok ( ) , "" }
6163 end
6264
6365 def exec_command ( unparsed_command , output_fun ) do
@@ -237,12 +239,7 @@ defmodule RabbitMQCtl do
237239 end
238240 end
239241
240- @ spec handle_shutdown ( :ok ) :: no_return ( )
241- defp handle_shutdown ( :ok ) do
242- exit_program ( 0 )
243- end
244-
245- @ spec handle_shutdown ( { :error , integer ( ) , nil } ) :: no_return ( )
242+ @ spec handle_shutdown ( { :error , integer ( ) , nil } | atom ( ) ) :: no_return ( )
246243 defp handle_shutdown ( { :error , exit_code , nil } ) do
247244 exit_program ( exit_code )
248245 end
0 commit comments