Sha256: 820977ac5fa3c21e7afe16979cd693dc416d7a449591d56ce95f1853493ad9cc

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8
# Author: kimoto
require 'vrowser'
require 'optparse'

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
  }
}
parser.parse!

if options[:config_path].nil?
  parser.help.display
  exit(1)
end

Vrowser.load_file(options[:config_path]) do |vrowser|
  case sub_command = ARGV.shift
  when "fetch"
    vrowser.fetch
  when "update"
    vrowser.update
    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
  else
    raise ArgumentError
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vrowser-0.0.1 bin/vrowser