Skip to content
Snippets Groups Projects
Commit c740bbb7 authored by Alex Reisner's avatar Alex Reisner
Browse files

Prevent coordinates from being parsed as argument.

Fixes #493.
parent a71785a4
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,11 @@ module Geocoder ...@@ -8,6 +8,11 @@ module Geocoder
show_url = false show_url = false
show_json = false show_json = false
# remove arguments that are probably coordinates so they are not
# processed as arguments (eg: -31.96047031,115.84274631)
coords = args.select{ |i| i.match(/^-\d/) }
args -= coords
OptionParser.new{ |opts| OptionParser.new{ |opts|
opts.banner = "Usage:\n geocode [options] <location>" opts.banner = "Usage:\n geocode [options] <location>"
opts.separator "\nOptions: " opts.separator "\nOptions: "
...@@ -65,7 +70,9 @@ module Geocoder ...@@ -65,7 +70,9 @@ module Geocoder
end end
}.parse!(args) }.parse!(args)
query = args.join(" ") # concatenate args with coords that might have been removed
# before option processing
query = (args + coords).join(" ")
if query == "" if query == ""
out << "Please specify a location (run `geocode -h` for more info).\n" out << "Please specify a location (run `geocode -h` for more info).\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment