#!/usr/bin/env ruby
=begin
Copyright (C) 2004  OHBAYASHI Ippei, YOSHIDA Yuichi, HARA Yutaka
Copyright (C) 2004  Kyoto univ. Microcomputer Club

Ruby Refactoring Browser is distributed under the same term as Ruby.
=end

require 'rrb/emacs_interface'

if $0 == __FILE__ then
  if ARGV.empty? then
    print RRB::EmacsInterface::USAGE
    exit
  end
  
  begin
    interface = RRB::EmacsInterface.new( ARGV )
    if interface.enable_refactor? then
      interface.refactor
      interface.output
    else
      STDERR << interface.get_last_error
      exit 1
    end
  rescue
    STDERR << "ERROR: exeption raised: #{$!.message}\n"
    STDERR << "stacktrace: \n"
    STDERR.puts $!.backtrace
    exit 2
  end
  
end
