This project is archived and is in readonly mode.
dbconsole arguments order mismatch
-
Ryan Bigg
Automatic cleanup of spam.
-
Vijay Dev
- Tag set to railties
Won't it be easier to just change the Usage to specify environment first and then the options? :)
@Andrei: Applying the patch fails. Please check it against master.
-
Vijay Dev
If someone decides, we can change the usage message, attaching the simple patch.
-
Andrei Kulakov
Renewed patch.
-
Xavier Noria
I think it is more common to have options first, arguments later, generally speaking. I'd vote for revising the implementation.
-
Andrei Kulakov
Renewed patch. Maybe there is a better implementation.
-
Xavier Noria
- Assigned user set to Xavier Noria
I have not debugged the issue, but this should easily work correctly with optparse. I mean, no manual option handling if possible, better to use a standard library that solves that.
Could you give it a whirl please?
-
Andrei Kulakov
I couldn't make it load correct database, when I set
ENV['RAILS_ENV']within block ofopt.on.opt.on("-e", "--environment=name", String, "Specifies the environment to load database for (test/development/production).", "Default: development") do |env| ENV['RAILS_ENV'] = %w(production development test).detect { |e| e =~ /^#{env}/} || env endI think manual option handling has something to do with warning in this comment:
# Has to set the RAILS_ENV before config/application is required if ARGV.first && !ARGV.first.index("-") && env = ARGV.first ENV['RAILS_ENV'] = %w(production development test).find { |e| e.index(env) } || env endCould you give it a whirl please?
Apologies for my knowledge of English, could you rephrase that please.
-
Andrei Kulakov
Regular
rails consolehas usage message:Usage: console [environment] [options]and similar option handling implementation to
dbconsole.But
rails serverspecifies environment through option:-e, --environment=name Specifies the environment to run this server under (test/development/production). Default: development -
Xavier Noria
Yes there are counterexamples, for example find(1) needs the directory first, and then options. But I think the most common interface is options, then arguments.
A pity Rails commands are not consistent there. Maybe something worth taking into account for the next major revision.
