couchrest_model/bin/couchapp

58 lines
1.3 KiB
Plaintext
Raw Normal View History

2008-09-16 17:14:36 +02:00
#!/usr/bin/env ruby
require 'optparse'
require File.expand_path(File.dirname(__FILE__)) + '/../lib/couchrest'
options = {
:loud => true,
}
opts = OptionParser.new do |opts|
opts.banner = "Usage: #$0 [options] (push|pull|generate)"
opts.on('-q', '--quiet', "Omit extra debug info") do
options[:loud] = false
end
opts.on_tail('-h', '--help', "Display detailed help and exit") do
puts opts
exit
end
end
opts.parse!(ARGV)
case ARGV.shift
when /generate/
appname = ARGV.shift
current = Dir.getwd
appdir = File.join(current, appname)
puts "generating couchapp in #{appdir}"
CouchRest::FileManager.generate_app(appdir)
when /push/
dirname = ARGV.shift
2008-09-16 18:10:45 +02:00
current = Dir.getwd
dir = File.expand_path(File.join(current, dirname))
dirapp = File.split(dir).last
2008-09-16 17:14:36 +02:00
if ARGV.length == 2
appname = ARGV.shift
dbstring = ARGV.shift
elsif ARGV.length == 1
2008-09-16 18:10:45 +02:00
appname = dirapp
2008-09-16 17:14:36 +02:00
dbstring = ARGV.shift
else
puts opts
puts "push dirname [appname] database"
exit(0)
end
2008-10-29 20:13:22 +01:00
CouchRest.database!(dbstring)
2008-09-16 17:14:36 +02:00
dbspec = CouchRest.parse(dbstring)
fm = CouchRest::FileManager.new(dbspec[:database], dbspec[:host])
2008-09-16 18:10:45 +02:00
fm.push_app(dir, appname)
2008-10-28 04:08:43 +01:00
2008-09-16 17:14:36 +02:00
when /pull/
2008-10-28 03:58:56 +01:00
puts "pull is not yet implemented"
2008-09-16 17:14:36 +02:00
else
puts opts
puts "please specify a command"
end