bin/vrowser in vrowser-0.0.1 vs bin/vrowser in vrowser-0.0.2
- old
+ new
@@ -1,17 +1,23 @@
#!/usr/bin/env ruby
# encoding: utf-8
# Author: kimoto
require 'vrowser'
require 'optparse'
+require 'vrowser/http_daemon'
options = {}
parser = OptionParser.new{ |opts|
opts.banner = "Usage: #{File.basename($0)}"
opts.on("-f", "--config-file=PATH", "specify config file"){ |v|
options[:config_path] = v
}
+
+ opts.on("-h", "--host=HOST", "host"){ |v| options[:host] = v }
+ opts.on("-p", "--port=PORT", "port"){ |v| options[:port] = v }
+ opts.on("-r", "--document-root=PATH", "root"){ |v| options[:document_root] = v }
+
}
parser.parse!
if options[:config_path].nil?
parser.help.display
@@ -27,9 +33,20 @@
vrowser.clear
when "list"
puts vrowser.servers.map(&:name).join($/)
when "json"
vrowser.active_servers.select(:name, :host, :ping, :num_players, :type, :map, :players).order(:host).map(&:values).to_json.display
+ when "daemon"
+ unless options[:host] and options[:port] and options[:document_root]
+ raise ArgumentError
+ end
+
+ Vrowser::HTTPDaemon.start(
+ :Host => options[:host],
+ :Port => options[:port],
+ :DocumentRoot => options[:document_root],
+ :config_path => options[:config_path])
else
- raise ArgumentError
+ raise ArgumentError(sub_command)
end
end
+