Sha256: 5e01bdaadc0a5e3ce25fbff4101bd474a2a1badbd0fa7dc7b6f695db98efcb46
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH << File.dirname(__FILE__) + "/../lib" if $0 == __FILE__ require 'optparse' require 'seventeen_mon' CONFIG = {} OPERATIONS = %w(ip address) option_parser = OptionParser.new do |opts| opts.banner = "Seventeen Mon #{SeventeenMon::VERSION}, a location finder for human\n" \ "Usage: #{File.basename(__FILE__)} [#{OPERATIONS.join('|')}] [pattern]" opts.separator <<-EOS Supported commands: ip [pattern] Display the location by ip address [pattern] Display the location by address Example: seventeen ip 188.74.78.234 seventeen address http://ruby-lang.com Note: NSFW if you run seventeen as root. EOS end option_parser.parse! op = ARGV.shift if OPERATIONS.include?(op) begin result = SM.send("find_by_#{op}".to_sym, ARGV.first) if result.is_a? Hash puts <<-EOS Country: #{result[:country]} Province: #{result[:province]} City: #{result[:city]} EOS else puts "N/A" end rescue ArgumentError => ex puts ex.message rescue Exception => e puts "Mmmmm, I didn't expect this:" puts e.message puts e.backtrace.join("\n") end else puts option_parser.help end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
seventeen_mon_new-1.0.0 | bin/seventeen |
seventeen_mon-1.0.2 | bin/seventeen |