couchrest_model/bin/couchview

51 lines
1.3 KiB
Plaintext
Raw Normal View History

2008-06-01 20:21:21 +02:00
#!/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)
2008-06-01 20:21:21 +02:00
options[:command] = ARGV.shift
options[:directory] = ARGV.shift
options[:trailing_args] = ARGV
2008-06-01 20:21:21 +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
# The options hash now contains the resolved defaults
# and the overrides from the command line.
2008-06-01 20:21:21 +02:00
# Call your class and send it the options here
# cr = CouchRest::FileManager.new(options[:database_name])
2008-08-03 20:34:09 +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