5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# 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
rescue Exception => ex
$stderr.puts ex.message
exit 1
end
|