Created
September 11, 2008 18:21
-
-
Save topfunky/10282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby -w | |
require 'optparse' | |
require File.dirname(__FILE__) + "/../lib/couchrest" | |
# Set defaults | |
options = { | |
:verbose => false, | |
:design_name => "_design", | |
} | |
opts = OptionParser.new do |opts| | |
opts.banner = "Usage: #$0 [options] (push|generate) directory database" | |
opts.on('-v', '--verbose', "Print extra debug info") do | |
options[:verbose] = true | |
end | |
opts.on('-d', '--design-name [name]', "Use an alternate name. Defaults to #{options[:design_name]}") do |design_name| | |
options[:design_name] = design_name | |
end | |
opts.on_tail('-h', '--help', "Display this help and exit") do | |
puts opts | |
exit | |
end | |
end | |
opts.parse!(ARGV) | |
options[:command] = ARGV.shift | |
options[:directory] = ARGV.shift | |
options[:database] = ARGV.shift | |
# There must be a better way to check for extra required args | |
unless (["push", "generate"].include?(options[:command]) && options[:directory] && options[:database]) | |
puts(opts) | |
exit | |
end | |
# DEBUG | |
puts options.inspect | |
# The options hash now contains the resolved defaults | |
# and the overrides from the command line. | |
# Call your class and send it the options here | |
# cr = CouchRest::FileManager.new(options[:database_name]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment