Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

make dbconsole honor environment when options specified #213

Closed
wants to merge 1 commit into from

2 participants

@dre3k

Is it just reasonable to change dbconsole usage message?
From:
Usage: dbconsole [options] [environment]
to
Usage: dbconsole [environment] [options]

@fxn
Owner
fxn commented

I think it is more common to have options first, arguments later, generally speaking. I'd vote for revising the implementation.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2011
  1. @dre3k
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 3 deletions.
  1. +5 −3 railties/lib/rails/commands/dbconsole.rb
View
8 railties/lib/rails/commands/dbconsole.rb
@@ -11,6 +11,8 @@
module Rails
class DBConsole
+ MODES = ['html', 'list', 'line', 'column']
+
def self.start(app)
new(app).start
end
@@ -28,8 +30,8 @@ def start
include_password = true
end
- opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'],
- "Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode|
+ opt.on("--mode [MODE]", MODES,
+ "Automatically put the sqlite3 database in the specified mode (#{MODES.join(', ')}).") do |mode|
options['mode'] = mode
end
@@ -118,6 +120,6 @@ def find_cmd(*commands)
end
# Has to set the RAILS_ENV before config/application is required
-if ARGV.first && !ARGV.first.index("-") && env = ARGV.first
+if (arg = ARGV.last) && !arg.index("-") && !Rails::DBConsole::MODES.include?(arg) && env = arg
ENV['RAILS_ENV'] = %w(production development test).detect {|e| e =~ /^#{env}/} || env
end
Something went wrong with that request. Please try again.