module SR::CLI
Public Class Methods
call()
click to toggle source
# File lib/sr/cli.rb, line 5 def self.call options = {} parser = OptionParser.new do |opts| opts.on('-c', '--context=obj', 'set the sr context to obj') do |obj| options[:context] = eval(obj, TOPLEVEL_BINDING) end opts.on('-f [FILE]', 'suppress configuration (or load FILE)') do |f| if f && File.exist?(f) (options[:config_files] ||= []).push(File.expand_path(f)) else fail "#{f} is not a valid file" if f options[:config_files] = [] end end opts.on('-v', '--version', 'display sr version') do puts "sr #{SR::VERSION} [ruby #{RUBY_VERSION} #{RUBY_PLATFORM}]" exit end opts.on('-h', '--help', 'display this message') do puts opts exit end end parser.parse!(ARGV) SR.repl(options) rescue SystemExit # Do nothing -- this exists so the exception handling below doesn't pick # up system exits from the option parser itself. rescue Exception => ex $stderr.puts ex.message exit 1 end