-
Notifications
You must be signed in to change notification settings - Fork 2
/
dietrb
executable file
·47 lines (38 loc) · 1.46 KB
/
dietrb
1
2
3
4
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
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby
require 'irb'
unless ARGV.empty?
require 'optparse'
ignore_irbrc = false
OptionParser.new do |opt|
bin = File.basename($0)
opt.banner = "Usage: #{bin} [options] [programfile] [arguments]"
opt.on("-f", "Ignore ~/.irbrc") { |ignore| ignore_irbrc = ignore }
opt.on("-r load-lib", "Loads the given library (same as `ruby -r')") { |lib| require lib }
opt.on("-d", "Set $DEBUG to true (same as `ruby -d')") { $DEBUG = true }
opt.on("-I path", "Add path to $LOAD_PATH") { |path| $LOAD_PATH.unshift(path) }
opt.on("--noinspect", "Don't use inspect for output") { IRB.formatter.inspect = false }
opt.on("--simple-prompt", "Simple prompt mode") { IRB.formatter.prompt = :simple }
opt.on("--noprompt", "No prompt mode") { IRB.formatter.prompt = nil }
opt.on("-v", "--version", "Print the version of #{bin}") do
$stdout.puts IRB::VERSION::DESCRIPTION
exit
end
end.parse!(ARGV)
end
unless ignore_irbrc
irbrc = File.expand_path("~/.irbrc")
load(irbrc) if File.exist?(irbrc)
end
IRB.formatter.filter_from_backtrace << /^#{__FILE__}/
if ARGV.empty?
require 'irb/driver/readline'
# require 'irb/driver/tty'
# require 'irb/driver/socket'
else
path = ARGV.shift
require 'irb/driver/file'
IRB::Driver.current = IRB::Driver::File.new(path)
end
irb(self, TOPLEVEL_BINDING.dup)
# TODO make sure!
puts "ENDED! and this message should show up on stdout"