diff options
Diffstat (limited to 'railties/lib/rails/commands')
-rw-r--r-- | railties/lib/rails/commands/commands_tasks.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/console.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/dbconsole.rb | 19 | ||||
-rw-r--r-- | railties/lib/rails/commands/destroy.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/generate.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/plugin.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 24 | ||||
-rw-r--r-- | railties/lib/rails/commands/update.rb | 9 |
8 files changed, 36 insertions, 30 deletions
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb index 6cfbc70c51..8bae08e44e 100644 --- a/railties/lib/rails/commands/commands_tasks.rb +++ b/railties/lib/rails/commands/commands_tasks.rb @@ -127,7 +127,7 @@ EOT require 'rails/generators' require_application_and_environment! Rails.application.load_generators - require "rails/commands/#{command}" + require_command!(command) end # Change to the application's path if there is no config.ru file in current directory. diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 555d8f31e1..96ced3c2f9 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -18,12 +18,12 @@ module Rails opt.on("-e", "--environment=name", String, "Specifies the environment to run this console under (test/development/production).", "Default: development") { |v| options[:environment] = v.strip } - opt.on("--debugger", 'Enable the debugger.') do |v| + opt.on("--debugger", 'Enables the debugger.') do |v| if RUBY_VERSION < '2.0.0' options[:debugger] = v else - puts "=> Notice: debugger option is ignored since ruby 2.0 and " \ - "it will be removed in future versions" + puts "=> Notice: debugger option is ignored since Ruby 2.0 and " \ + "it will be removed in future versions." end end opt.parse!(arguments) diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 1a2613a8d0..0d8b3de0eb 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -44,7 +44,7 @@ module Rails find_cmd_and_exec(['mysql', 'mysql5'], *args) - when "postgresql", "postgres", "postgis" + when /^postgres|^postgis/ ENV['PGUSER'] = config["username"] if config["username"] ENV['PGHOST'] = config["host"] if config["host"] ENV['PGPORT'] = config["port"].to_s if config["port"] @@ -74,6 +74,21 @@ module Rails find_cmd_and_exec('sqlplus', logon) + when "sqlserver" + args = [] + + args += ["-D", "#{config['database']}"] if config['database'] + args += ["-U", "#{config['username']}"] if config['username'] + args += ["-P", "#{config['password']}"] if config['password'] + + if config['host'] + host_arg = "#{config['host']}" + host_arg << ":#{config['port']}" if config['port'] + args += ["-S", host_arg] + end + + find_cmd_and_exec("sqsh", *args) + else abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!" end @@ -163,7 +178,7 @@ module Rails found = commands.detect do |cmd| dirs_on_path.detect do |path| full_path_command = File.join(path, cmd) - File.executable? full_path_command + File.file?(full_path_command) && File.executable?(full_path_command) end end diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 5479da86a0..ce26cc3fde 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,5 +1,7 @@ require 'rails/generators' +#if no argument/-h/--help is passed to rails destroy command, then +#it generates the help associated. if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'destroy' exit diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 351c59c645..926c36b967 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,5 +1,7 @@ require 'rails/generators' +#if no argument/-h/--help is passed to rails generate command, then +#it generates the help associated. if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'generate' exit diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index 95bbdd4cdf..52d8966ead 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -11,7 +11,7 @@ else end if File.exist?(railsrc) extra_args_string = File.read(railsrc) - extra_args = extra_args_string.split(/\n+/).flat_map {|l| l.split} + extra_args = extra_args_string.split(/\n+/).flat_map(&:split) puts "Using #{extra_args.join(" ")} from #{railsrc}" ARGV.insert(1, *extra_args) end diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index c3b7bb6f84..3f14910edf 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -20,20 +20,20 @@ module Rails def option_parser(options) OptionParser.new do |opts| - opts.banner = "Usage: rails server [mongrel, thin, etc] [options]" + opts.banner = "Usage: rails server [mongrel, thin etc] [options]" opts.on("-p", "--port=port", Integer, "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: 0.0.0.0") { |v| options[:Host] = v } + opts.on("-b", "--binding=IP", String, + "Binds Rails to the specified IP.", "Default: localhost") { |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 the debugger") do + "Uses a custom rackup configuration.") { |v| options[:config] = v } + opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true } + opts.on("-u", "--debugger", "Enables the debugger.") do if RUBY_VERSION < '2.0.0' options[:debugger] = true else - puts "=> Notice: debugger option is ignored since ruby 2.0 and " \ - "it will be removed in future versions" + puts "=> Notice: debugger option is ignored since Ruby 2.0 and " \ + "it will be removed in future versions." end end opts.on("-e", "--environment=name", String, @@ -45,7 +45,7 @@ module Rails opts.separator "" - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } + opts.on("-h", "--help", "Shows this help message.") { puts opts; exit } end end end @@ -126,15 +126,11 @@ module Rails puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}" puts "=> Run `rails server -h` for more startup options" - if options[:Host].to_s.match(/0\.0\.0\.0/) - puts "=> Notice: server is listening on all interfaces (#{options[:Host]}). Consider using 127.0.0.1 (--binding option)" - end - puts "=> Ctrl-C to shutdown server" unless options[:daemonize] end def create_tmp_directories - %w(cache pids sessions sockets).each do |dir_to_make| + %w(cache pids sockets).each do |dir_to_make| FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make)) end end diff --git a/railties/lib/rails/commands/update.rb b/railties/lib/rails/commands/update.rb deleted file mode 100644 index 59fae5c337..0000000000 --- a/railties/lib/rails/commands/update.rb +++ /dev/null @@ -1,9 +0,0 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) - -if ARGV.size == 0 - Rails::Generators.help - exit -end - -name = ARGV.shift -Rails::Generators.invoke name, ARGV, behavior: :skip |