2008-06-01 20:21:21 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2008-09-11 22:29:12 +02:00
|
|
|
require 'optparse'
|
2008-09-12 23:55:23 +02:00
|
|
|
require 'couchrest'
|
|
|
|
|
2008-09-12 07:48:17 +02:00
|
|
|
%w(generate push).each do |file|
|
|
|
|
require File.dirname(__FILE__) + "/../lib/couchrest/commands/#{file}"
|
|
|
|
end
|
2008-09-11 22:29:12 +02:00
|
|
|
|
|
|
|
# Set defaults
|
|
|
|
options = {
|
|
|
|
:loud => true,
|
|
|
|
}
|
|
|
|
|
|
|
|
opts = OptionParser.new do |opts|
|
|
|
|
opts.banner = "Usage: #$0 [options] (push|generate) directory database"
|
|
|
|
opts.on('-q', '--quiet', "Omit extra debug info") do
|
|
|
|
options[:loud] = false
|
|
|
|
end
|
|
|
|
opts.on_tail('-h', '--help [push|generate]', "Display detailed help and exit") do |help_command|
|
|
|
|
puts opts
|
|
|
|
case help_command
|
|
|
|
when "push"
|
|
|
|
puts CouchRest::Commands::Push.help
|
|
|
|
when "generate"
|
|
|
|
puts CouchRest::Commands::Generate.help
|
|
|
|
end
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
opts.parse!(ARGV)
|
2008-06-01 20:21:21 +02:00
|
|
|
|
2008-09-11 22:29:12 +02:00
|
|
|
options[:command] = ARGV.shift
|
|
|
|
options[:directory] = ARGV.shift
|
|
|
|
options[:trailing_args] = ARGV
|
2008-06-01 20:21:21 +02:00
|
|
|
|
2008-09-11 22:29:12 +02:00
|
|
|
# There must be a better way to check for extra required args
|
|
|
|
unless (["push", "generate"].include?(options[:command]) && options[:directory] && options[:trailing_args])
|
|
|
|
puts(opts)
|
2008-06-01 20:21:21 +02:00
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
2008-09-11 22:29:12 +02:00
|
|
|
case options[:command]
|
|
|
|
when "push"
|
|
|
|
CouchRest::Commands::Push.run(options)
|
|
|
|
when "generate"
|
|
|
|
CouchRest::Commands::Generate.run(options)
|
2008-06-01 21:23:04 +02:00
|
|
|
end
|