From 0d21460c7516a0c62bd47d530a9750b452e60e4e Mon Sep 17 00:00:00 2001 From: otherl Date: Sat, 28 Sep 2013 19:56:11 +0100 Subject: Changed status to take an optional argument. Fixed a bug that caused the weight to default to nil if an unrecognised weight was given. --- blatube.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blatube.rb b/blatube.rb index da208cc..82f5009 100644 --- a/blatube.rb +++ b/blatube.rb @@ -23,10 +23,10 @@ args = ARGV.dup options = OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)} -h" - opts.on( '-s', '--status LINE', 'Get the current status of a tube line.' ) {|l| @line = l } + opts.on( '-s', '--status [LINE]', 'Get the current status of a tube line.' ) {|l| @line = l || 'summary' } opts.on( '-f', '--from-station STATION', 'Find route from this station.' ) {|f| @from_station = f } opts.on( '-t', '--to-station STATION', 'Find route to this station.' ) {|t| @to_station = t } - opts.on( '-w', '--weight WEIGHT', 'Shortest route using either distance, peak_time, off_peak_time or unimpeded_time.' ) {|w| @weight = w if WEIGHTS.include? w || 'peak_time' } + opts.on( '-w', '--weight WEIGHT', 'Shortest route using either distance, peak_time, off_peak_time or unimpeded_time.' ) {|w| @weight = WEIGHTS.include?(w) ? w : 'peak_time' } opts.on( '-c', '--change-time TIME', 'Your expected average change time in minutes.' ) {|c| @change_time = c.to_f.round(2) } opts.on( '-C', '--colour', 'Enable line colours in the output.' ) { @colour = true } opts.on( '-d', '--debug', 'Display debug info.' ) { debug = true } -- cgit v1.2.3