-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.rb
29 lines (25 loc) · 859 Bytes
/
shell.rb
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
#!/usr/bin/env ruby
# encoding: utf-8
drchord_dir = File.expand_path(File.dirname(__FILE__))
begin
ENV['BUNDLE_GEMFILE'] = File.expand_path(File.join(drchord_dir, 'Gemfile'))
require 'bundler/setup'
rescue LoadError
puts "Error: 'bundler' not found. Please install it with `gem install bundler`."
exit
end
require 'optparse'
options = {:node => "druby://127.0.0.1:3000"}
OptionParser.new do |opt|
opt.banner = "Usage: ruby #{File.basename($0)} [options]"
opt.on('-n --node', 'IP_ADDR:PORT') {|v| options[:node] = "druby://#{v}" }
opt.on_tail('-h', '--help', 'show this message') {|v| puts opt; exit }
begin
opt.parse!
rescue OptionParser::InvalidOption
puts "Error: Invalid option. \n#{opt}"; exit
end
end
require File.expand_path(File.join(drchord_dir, '/lib/shell/shell.rb'))
shell = DRChord::DHTShell.new(options)
shell.run