From 856ad6cee9fc261eda30942e638b77b450334023 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Fri, 22 Apr 2011 12:55:23 -0400 Subject: [PATCH] Change CLI output format. Show all globally-supported attributes in a table. --- lib/geocoder/cli.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/geocoder/cli.rb b/lib/geocoder/cli.rb index 88e12e58..0a866b72 100644 --- a/lib/geocoder/cli.rb +++ b/lib/geocoder/cli.rb @@ -75,8 +75,18 @@ module Geocoder end if (result = Geocoder.search(query).first) - out << result.coordinates.join(',') + "\n" - out << result.address + "\n" + lines = [ + ["Latitude", :latitude], + ["Longitude", :longitude], + ["Full address", :address], + ["City", :city], + ["State/province", :state], + ["Postal code", :postal_code], + ["Country", :country], + ] + lines.each do |line| + out << (line[0] + ": ").ljust(18) + result.send(line[1]).to_s + "\n" + end exit 0 else out << "Location '#{query}' not found.\n" -- GitLab