couchrest_model/bin/couchview
Geoffrey Grosenbach 447ae7de5a Removed comment
2008-09-11 20:41:03 -07:00

44 lines
1.1 KiB
Ruby
Executable file

#!/usr/bin/env ruby
require 'optparse'
require File.dirname(__FILE__) + "/../lib/couch_rest/commands"
# 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)
options[:command] = ARGV.shift
options[:directory] = ARGV.shift
options[:trailing_args] = ARGV
# 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)
exit
end
case options[:command]
when "push"
CouchRest::Commands::Push.run(options)
when "generate"
CouchRest::Commands::Generate.run(options)
end