Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Commit 0644cb3

Browse files
committed
added ability to just use a -m flag with autodetect
1 parent 75dbaf1 commit 0644cb3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ip_utils/ip_geo.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,30 @@
6868
response = RestClient.get(url)
6969
info = JSON.parse(response)
7070

71+
if info['status'] == 'fail'
72+
puts 'No IP info'
73+
else
74+
if opt == 'ip'
75+
puts info['query']
76+
elsif opt == 'city'
77+
puts info['city']
78+
elsif opt == 'region'
79+
puts info['region']
80+
elsif opt == 'country'
81+
puts info['country']
82+
elsif opt == 'zip'
83+
puts info['zip']
84+
elsif opt == 'isp'
85+
puts info['isp']
86+
else
87+
puts 'Bad input'
88+
end
89+
end
90+
elsif opt != nil && arg == nil
91+
url = "http://ip-api.com/json/#{arg.join}"
92+
response = RestClient.get(url)
93+
info = JSON.parse(response)
94+
7195
if info['status'] == 'fail'
7296
puts 'No IP info'
7397
else

0 commit comments

Comments
 (0)