Sha256: c5da6a886d09ca0e70f7e093fb06d80ad8b503563dcd52e8ea88a17c4beea414

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

#!/usr/bin/env ruby

begin
  require 'kangaroo'
rescue LoadError
  begin
    require 'rubygems'
    require 'kangaroo'
  rescue LoadError
    require 'bundler/setup'
    require 'kangaroo'
  end
end

require 'ostruct'
require 'optparse'
options = {}

optparse = OptionParser.new do |opts|
  opts.banner = "Usage: kang -c config_file.yaml"
  
  options[:config_file] = nil
  opts.on '-c', '--config FILE', 'Specify config file' do |file|
    options[:config_file] = file
  end   
  
  # This displays the help screen, all programs are
  # assumed to have this option.
  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end
end

optparse.parse!

Kang = OpenStruct.new
Kang.logger = Logger.new(STDOUT)

Kang.class_eval do
  def inspect
    "Kang console"
  end
  
  def init file_or_hash    
    Kang.logger.info "Loading Kangaroo configuration #{file_or_hash.inspect}"
    Kang.config = Kangaroo::Util::Configuration.new file_or_hash, Kang.logger
    Kang.config.login
  
    Kangaroo::Util::Loader.new('res.*', Kang.config.database).load!
    true
  end
end

options[:config_file] && Kang.init(options[:config_file])

require 'irb'
require 'irb/completion'

Hirb.enable
IRB.start



















Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kangaroo-0.0.3 bin/kang
kangaroo-0.0.2 bin/kang