#!/usr/bin/env ruby
#
# = BioRuby shell - command line interface for the BioRuby library
#
# Copyright::   Copyright (C) 2005, 2006, 2007
#               Toshiaki Katayama <k@bioruby.org>
# License::     The Ruby License
#
# $Id:$
#

begin
  require 'rubygems'
  gem 'bio', '>= 1.1.0'
rescue LoadError
  require 'bio'
end
require 'bio/shell'

# required to run commands (getseq, ls etc.)
include Bio::Shell

# setup command line options, working directory, and irb configurations
Bio::Shell::Setup.new

# loading workspace and command history
Bio::Shell.load_session

# sets default email address for Entrez eUtils.
Bio::NCBI.default_email ||= 'staff@bioruby.org'

# main loop
if Bio::Shell.cache[:rails]
  Bio::Shell.cache[:rails].join
else
  Signal.trap("SIGINT") do
    Bio::Shell.cache[:irb].signal_handle
  end

  catch(:IRB_EXIT) do
    Bio::Shell.cache[:irb].eval_input
  end
end

# saving workspace, command history and configuration before exit
Bio::Shell.save_session

