robmathers / WhereAmI

A quick command line tool for OS X to get your geographic coordinates using the CoreLocation framework.
MIT License
198 stars 20 forks source link

Not an issue as well, I've made a Brew cask #4

Open welldan97 opened 8 years ago

welldan97 commented 8 years ago

If anyone interested, you can install robmathers/WhereAmI via Homebrew cask by tapping welldan97/whereami:

$ brew tap welldan97/whereami
==> Tapping welldan97/whereami
Cloning into '/opt/boxen/homebrew/Library/Taps/welldan97/homebrew-whereami'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
Checking connectivity... done.
Tapped 0 formulae (28 files, 17.2K)

$ brew cask install whereami
==> Downloading https://github.com/robmathers/WhereAmI/releases/download/v1.02/whereami-1.02.zip
######################################################################## 100.0%
==> Verifying checksum for Cask whereami
==> Symlinking Binary 'whereami' to '/usr/local/bin/whereami'
🍺  whereami staged at '/opt/homebrew-cask/Caskroom/whereami/latest' (36K)

$ whereami
Latitude: 56.320993
Longitude: 44.027497
Accuracy (m): 65.000000
Timestamp: 01/03/2016, 12:11:27 GMT+3
welldan97 commented 8 years ago

Also I've made a small script:

#!/usr/bin/env bash

set -e

main() {
  output=''
  while ! does-include "$output" 'Latitude' ; do
    output=$(whereami)
  done
  echo $(fetch "$output" 'Latitude') $(fetch "$output" 'Longitude')
}

fetch() {
  echo "$1" | grep "$2" | head -n 1 | cut -d' ' -f2
}

does-include() {
  echo "$1" | grep "$2" > /dev/null
}

main "$@"

It makes output more consistent - remove duplicates, keeps retrying till return results, and returns just latitude and longitude, i.e.:

$ w97-whereami
56.320956 44.027472
Joilence commented 3 years ago
$ brew cask install whereami
==> Downloading https://github.com/robmathers/WhereAmI/releases/download/v1.02/whereami-1.02.zip
######################################################################## 100.0%
==> Verifying checksum for Cask whereami
==> Symlinking Binary 'whereami' to '/usr/local/bin/whereami'
🍺  whereami staged at '/opt/homebrew-cask/Caskroom/whereami/latest' (36K)

Now brew cask install is deprecated; just use brew install is okay. And tested on Apple Silicon with macOS 11.3, it works fine.

BTW, @welldan97 it warns me Warning: Unexpected method 'license' called on Cask whereami. when I tapped your formula; probably you can fix that.