#!/usr/bin/env ruby require 'rubygems' require 'templater' require '' require File.join(File.dirname(__FILE__), '..','generators','rhoconnect') $:.unshift File.join(File.dirname(__FILE__),'..','lib') require File.join(File.dirname(__FILE__), '..','lib','rhoconnect') # CONSTANTS OPTIONS = {'start' => 'Start the rhoconnect service.', 'stop' => 'Stop the rhoconnect service.', 'restart' => 'Stop and then start the rhoconnect service.'} # CLASSES # Stub this method to force 1.8 compatibility (come on templater!) class Encoding def find "utf-8" end def dummy? false end end class String def force_encoding(enc) return self end def encoding if RUBY_VERSION =~ /1\.8/ and Encoding.responds_to?('new') Encoding.new else Encoding.default_external end end end # METHODS # check_options # Verifies that the options passed in are part of the valid options set # (Only for non-generation operations) def check_options option_names = OPTIONS.keys ARGV.each do |opt| if !option_names.include? opt puts "Unknown option: #{opt}" print_usage exit end #if end #do end #check_options # print_usage # Displays usage information for non-generation operations def print_usage usage = "Usage: #{$0} [options]\n\n" + "General Options:\n" # Compile valid options from OPTIONS hash OPTIONS.each do |key, value| usage << sprintf(" %-32s %s", key, value) end #do puts usage end #print_usage # SCRIPT # Determine whether rhoconnect is being used for generation or not if !ARGV.include? 'app' and !ARGV.include? 'source' check_options else Rhoconnect.run_cli(Dir.pwd, 'rhoconnect', Rhoconnect::VERSION, ARGV) end #if