lib/taps/cli.rb in taps2-0.5.2 vs lib/taps/cli.rb in taps2-0.5.3

- old
+ new

@@ -3,11 +3,11 @@ require 'taps/monkey' require 'taps/config' require 'taps/log' require 'vendor/okjson' -Taps::Config.taps_database_url = ENV['TAPS_DATABASE_URL'] || begin +Taps::Config.taps_database_url = ENV['TAPS_DATABASE_URL'] || ENV['DATABASE_URL'] || begin # this is dirty but it solves a weird problem where the tempfile disappears mid-process require 'sqlite3' $__taps_database = Tempfile.new('taps.db') $__taps_database.open() "sqlite://#{$__taps_database.path}" @@ -71,19 +71,19 @@ puts Taps.version end def help puts <<EOHELP - Options - ======= - server Start a taps database import/export server - pull Pull a database from a taps server - push Push a database to a taps server - version Taps version +Options +======= +server Start a taps database import/export server +pull Pull a database from a taps server +push Push a database to a taps server +version Taps version - Add '-h' to any command to see their usage - EOHELP +Add '-h' to any command to see their usage +EOHELP end def serveroptparse opts={:port => 5000, :database_url => nil, :login => nil, :password => nil, :debug => false} OptionParser.new do |o| @@ -93,11 +93,11 @@ o.on("-p", "--port=N", "Server Port") { |v| opts[:port] = v.to_i if v.to_i > 0 } o.on("-d", "--debug", "Enable Debug Messages") { |v| opts[:debug] = true } o.parse!(argv) opts[:database_url] = argv.shift - opts[:login] = argv.shift - opts[:password] = argv.shift + opts[:login] = argv.shift || ENV['TAPS_LOGIN'] + opts[:password] = argv.shift || ENV['TAPS_PASSWORD'] if opts[:database_url].nil? $stderr.puts "Missing Database URL" puts o exit 1