bin/coin_rack
#!/usr/bin/env ruby --
require "optparse"
# setup the options -----------------------------------------------------------
options = {}
parser = OptionParser.new do |opts|
opts.banner = "CoinRack Usage: coin_rack [options]"
desc = "Prints the location of the rackup file."
opts.on("-p", "--print", desc) { |value| options[:print] = value }
desc = "Starts the Rack server."
opts.on("-r", "--run", desc) { |value| options[:run] = value }
opts.on_tail("-h", "--help", "Show this message.") do
puts opts
exit
end
end
parser.parse!
if options.values.compact.empty?
puts parser.banner
puts parser.summarize
exit
end
path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
rackup_file = File.join(path, "config.ru")
if options[:print]
puts rackup_file
exit
end
if options[:run]
exec "cd #{path} && rackup"
exit
end