From eb63faaa1af7ef28ae1a716d068acc447e28c174 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Fri, 18 Jan 2019 09:53:12 +0900 Subject: Revert "Remove deprecated `server` argument from the rails server command" This reverts commit fa791fb8e2a718b5d0430c7ca5a454678dfc192d. Reason: `server` argument was deprecated in Rails 6.0. Ref: #32058. --- .../lib/rails/commands/server/server_command.rb | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index 20694e7e39..47c3f05bb3 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -98,6 +98,8 @@ module Rails DEFAULT_PORT = 3000 DEFAULT_PID_PATH = "tmp/pids/server.pid" + argument :using, optional: true + class_option :port, aliases: "-p", type: :numeric, desc: "Runs Rails on the specified port - defaults to 3000.", banner: :port class_option :binding, aliases: "-b", type: :string, @@ -124,6 +126,7 @@ module Rails super @original_options = local_options - %w( --restart ) + deprecate_positional_rack_server_and_rewrite_to_option(@original_options) end def perform @@ -141,7 +144,7 @@ module Rails after_stop_callback = -> { say "Exiting" unless options[:daemon] } server.start(after_stop_callback) else - say rack_server_suggestion(options[:using]) + say rack_server_suggestion(using) end end end @@ -150,7 +153,7 @@ module Rails def server_options { user_supplied_options: user_supplied_options, - server: options[:using], + server: using, log_stdout: log_to_stdout?, Port: port, Host: host, @@ -259,6 +262,22 @@ module Rails FileUtils.rm_f(options[:pid]) if options[:restart] end + def deprecate_positional_rack_server_and_rewrite_to_option(original_options) + if using + ActiveSupport::Deprecation.warn(<<~MSG) + Passing the Rack server name as a regular argument is deprecated + and will be removed in the next Rails version. Please, use the -u + option instead. + MSG + + original_options.concat [ "-u", using ] + else + # Use positional internally to get around Thor's immutable options. + # TODO: Replace `using` occurrences with `options[:using]` after deprecation removal. + @using = options[:using] + end + end + def rack_server_suggestion(server) if server.in?(RACK_SERVERS) <<~MSG -- cgit v1.2.3