From 95b63c6a078527b747c99ab1c881fdfe6577518b Mon Sep 17 00:00:00 2001 From: Henrik N Date: Sat, 6 Feb 2010 12:48:02 +0100 Subject: Fix 'rails server -h' double help banner. Correct its usage line. [#3874 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/commands/server.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index b21ae2a17b..c27214d3c8 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -9,6 +9,7 @@ module Rails options = {} args = args.dup opt_parser = OptionParser.new do |opts| + opts.banner = "Usage: rails server [options]" opts.on("-p", "--port=port", Integer, "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v } opts.on("-b", "--binding=ip", String, @@ -48,7 +49,9 @@ module Rails super ensure - puts 'Exiting' unless options[:daemonize] + # The '-h' option calls exit before @options is set. + # If we call 'options' with it unset, we get double help banners. + puts 'Exiting' unless @options && options[:daemonize] end def middleware -- cgit v1.2.3 From f44a0b1d524064a2e919cd10d3013db680af9b17 Mon Sep 17 00:00:00 2001 From: RomD Date: Sat, 6 Feb 2010 17:18:10 +0100 Subject: fix usage examples and more to use new invocations Signed-off-by: Carl Lerche --- railties/lib/rails/commands/console.rb | 2 +- railties/lib/rails/commands/plugin.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index a984eff6e2..3fa4c939a8 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -19,7 +19,7 @@ module Rails opt.banner = "Usage: console [environment] [options]" opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } - opt.on('--irb') { |v| abort '--irb option is no longer supported. Invoke `/your/choice/of/ruby script/console` instead' } + opt.on('--irb') { |v| abort '--irb option is no longer supported. Invoke `/your/choice/of/ruby script/rails console` instead' } opt.parse!(ARGV) end diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index af12df1425..8bcd92a33b 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -2,7 +2,7 @@ # # Installing plugins: # -# $ ./script/plugin install continuous_builder asset_timestamping +# $ rails plugin install continuous_builder asset_timestamping # # Specifying revisions: # @@ -319,13 +319,13 @@ module Commands o.separator "" o.separator "EXAMPLES" o.separator " Install a plugin:" - o.separator " #{@script_name} install continuous_builder\n" + o.separator " #{@script_name} plugin install continuous_builder\n" o.separator " Install a plugin from a subversion URL:" - o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" + o.separator " #{@script_name} plugin install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" o.separator " Install a plugin from a git URL:" - o.separator " #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n" + o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n" o.separator " Install a plugin and add a svn:externals entry to vendor/plugins" - o.separator " #{@script_name} install -x continuous_builder\n" + o.separator " #{@script_name} plugin install -x continuous_builder\n" end end @@ -381,7 +381,7 @@ module Commands "Exports the plugin, allowing you to check it into your local repository. Does not enable updates, or add an svn:externals entry.") { |v| @method = :export } o.on( "-q", "--quiet", "Suppresses the output from installation.", - "Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true } + "Ignored if -v is passed (rails plugin -v install ...)") { |v| @options[:quiet] = true } o.on( "-r REVISION", "--revision REVISION", "Checks out the given revision from subversion or git.", "Ignored if subversion/git is not used.") { |v| @options[:revision] = v } -- cgit v1.2.3 From 39ebd6eb2b6c90756514798450eb15bdfec67be6 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 9 Feb 2010 08:40:06 -0800 Subject: rails runner loads environment after parsing command-line options --- railties/lib/rails/commands/runner.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 606e04483f..1570b9ab0d 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -35,6 +35,8 @@ ARGV.delete(code_or_file) ENV["RAILS_ENV"] = options[:environment] +require ENV_PATH + begin if code_or_file.nil? $stderr.puts "Run '#{$0} -h' for help." -- cgit v1.2.3 From af22c5b16a0f138969221e5a17fc159efb5ae347 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 9 Feb 2010 20:19:54 +0700 Subject: Add missing -h/--help flag to several rails command [#3909 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/commands/console.rb | 2 +- railties/lib/rails/commands/destroy.rb | 4 ++-- railties/lib/rails/commands/generate.rb | 4 ++-- railties/lib/rails/commands/performance/benchmarker.rb | 4 ++-- railties/lib/rails/commands/performance/profiler.rb | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 3fa4c939a8..50df6ba405 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -19,7 +19,7 @@ module Rails opt.banner = "Usage: console [environment] [options]" opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } - opt.on('--irb') { |v| abort '--irb option is no longer supported. Invoke `/your/choice/of/ruby script/rails console` instead' } + opt.on('--irb', "DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead") { |v| abort '--irb option is no longer supported. Invoke `/your/choice/of/ruby script/rails console` instead' } opt.parse!(ARGV) end diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 92a06ebdd8..9023c61bf2 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,7 +1,7 @@ require 'rails/generators' -if ARGV.size == 0 - Rails::Generators.help +if [nil, "-h", "--help"].include?(ARGV.first) + Rails::Generators.help 'destroy' exit end diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 5e45d8ab46..7d05a30de8 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,7 +1,7 @@ require 'rails/generators' -if ARGV.size == 0 - Rails::Generators.help +if [nil, "-h", "--help"].include?(ARGV.first) + Rails::Generators.help 'generate' exit end diff --git a/railties/lib/rails/commands/performance/benchmarker.rb b/railties/lib/rails/commands/performance/benchmarker.rb index ad84d94dbf..0432261802 100644 --- a/railties/lib/rails/commands/performance/benchmarker.rb +++ b/railties/lib/rails/commands/performance/benchmarker.rb @@ -1,5 +1,5 @@ -if ARGV.empty? - puts "Usage: benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." +if [nil, "-h", "--help"].include?(ARGV.first) + puts "Usage: rails benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." exit 1 end diff --git a/railties/lib/rails/commands/performance/profiler.rb b/railties/lib/rails/commands/performance/profiler.rb index 50ae411166..6d9717b5cd 100644 --- a/railties/lib/rails/commands/performance/profiler.rb +++ b/railties/lib/rails/commands/performance/profiler.rb @@ -1,5 +1,5 @@ -if ARGV.empty? - $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" +if [nil, "-h", "--help"].include?(ARGV.first) + $stderr.puts "Usage: rails profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" exit(1) end -- cgit v1.2.3 From f337ebc308b95671ba8620a0cc56f75c4fb11e15 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 9 Feb 2010 21:03:18 +0700 Subject: Add default values to output of 'rails server -h', hardcoded as Rack::Server did since options doesn't have any data at the time of parsing arguments [#3910 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/commands/server.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index c27214d3c8..281e4da3d2 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -11,16 +11,16 @@ module Rails opt_parser = OptionParser.new do |opts| opts.banner = "Usage: rails server [options]" opts.on("-p", "--port=port", Integer, - "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v } + "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v } opts.on("-b", "--binding=ip", String, - "Binds Rails to the specified ip.", "Default: #{options[:Host]}") { |v| options[:Host] = v } + "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v } opts.on("-c", "--config=file", String, "Use custom rackup configuration file") { |v| options[:config] = v } opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true } opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } opts.on("-e", "--environment=name", String, "Specifies the environment to run this server under (test/development/production).", - "Default: #{options[:environment]}") { |v| options[:environment] = v } + "Default: development") { |v| options[:environment] = v } opts.separator "" -- cgit v1.2.3 From cafe882d12d767f510d6b8ad283f49a1c02e82ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20Niemel=C3=A4?= Date: Tue, 9 Feb 2010 23:21:11 +0200 Subject: Fix server environment [#3877 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/commands/server.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 281e4da3d2..c57660c0d1 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -6,8 +6,8 @@ module Rails class Server < ::Rack::Server class Options def parse!(args) - options = {} - args = args.dup + args, options = args.dup, {} + opt_parser = OptionParser.new do |opts| opts.banner = "Usage: rails server [options]" opts.on("-p", "--port=port", Integer, @@ -34,13 +34,20 @@ module Rails end end + def initialize(*) + super + set_environment + end + def opt_parser Options.new end - def start - ENV["RAILS_ENV"] = options[:environment] + def set_environment + ENV["RAILS_ENV"] ||= options[:environment] + end + def start puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}" puts "=> Call with -d to detach" unless options[:daemonize] -- cgit v1.2.3