2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var ipinfo~ {|@argv|
|
2021-12-27 17:54:26 +00:00
|
|
|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
2021-08-24 18:45:25 +00:00
|
|
|
|
2021-08-27 19:45:39 +00:00
|
|
|
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
2021-08-24 18:45:25 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn url-of {|ip|
|
2021-12-27 17:54:26 +00:00
|
|
|
printf 'ipinfo.io/%s?token=%s' $ip $token
|
2021-08-24 18:45:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn info {|ip|
|
2021-08-24 18:45:25 +00:00
|
|
|
if (ip:is-ip $ip) {
|
2021-08-27 19:45:39 +00:00
|
|
|
var url = (url-of $ip)
|
2021-12-27 17:54:26 +00:00
|
|
|
printf "URL: %s\n" $url
|
2021-08-24 18:45:25 +00:00
|
|
|
e:curlie $url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
each $info~ $argv
|
|
|
|
}
|