aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/commands
diff options
context:
space:
mode:
authorBryan Ray <bryansray@gmail.com>2009-01-28 19:47:45 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-28 19:47:45 +0000
commitf725b1971072a2203d6d433149730289cbb80128 (patch)
treefefbdb41f6e120756a3893d169f9d58cb45ccb4f /railties/lib/commands
parent6079ec1f77daf364a2b25cf651e9b3c9e1b95a16 (diff)
downloadrails-f725b1971072a2203d6d433149730289cbb80128.tar.gz
rails-f725b1971072a2203d6d433149730289cbb80128.tar.bz2
rails-f725b1971072a2203d6d433149730289cbb80128.zip
Added options to script/dbconsole to sqlite3 console in various different modes. [#607 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'railties/lib/commands')
-rw-r--r--railties/lib/commands/dbconsole.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index 06848d3c91..8002264f7e 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -3,12 +3,23 @@ require 'yaml'
require 'optparse'
include_password = false
+options = {}
OptionParser.new do |opt|
opt.banner = "Usage: dbconsole [options] [environment]"
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
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|
+ options['mode'] = mode
+ end
+
+ opt.on("-h", "--header") do |h|
+ options['header'] = h
+ end
+
opt.parse!(ARGV)
abort opt.to_s unless (0..1).include?(ARGV.size)
end
@@ -60,8 +71,13 @@ when "sqlite"
exec(find_cmd('sqlite'), config["database"])
when "sqlite3"
- exec(find_cmd('sqlite3'), config["database"])
+ args = []
+
+ args << "-#{options['mode']}" if options['mode']
+ args << "-header" if options['header']
+ args << config['database']
+ exec(find_cmd('sqlite3'), *args)
else
abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!"
end