Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added options to script/dbconsole to sqlite3 console in various diffe…

…rent modes. [#607 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit f725b1971072a2203d6d433149730289cbb80128 1 parent 6079ec1
Bryan Ray authored lifo committed
Showing with 17 additions and 1 deletion.
  1. +17 −1 railties/lib/commands/dbconsole.rb
View
18 railties/lib/commands/dbconsole.rb
@@ -3,12 +3,23 @@
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 @@ def find_cmd(*commands)
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
Please sign in to comment.
Something went wrong with that request. Please try again.