From 42ad8a7cc806c1dc236530c19612fe947a50d15b Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 18 Oct 2010 22:05:24 -0700 Subject: Cleaner option parsing. --- omptagger | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'omptagger') diff --git a/omptagger b/omptagger index d2f191f..8ff72ce 100755 --- a/omptagger +++ b/omptagger @@ -430,8 +430,7 @@ class MP3 < Metadata end actions = Array.new -options = Array.new -scheme = '%n - %a - %t' +options = Hash[:scheme => '%n - %a - %t'] GetoptLong.new( ['--view', '-v', GetoptLong::NO_ARGUMENT], @@ -456,16 +455,16 @@ GetoptLong.new( when :info Output.additional_information when :scheme - scheme = argument + options[option] = argument when :nocolour, :pretend - options << option + options[option] = true when :viewtag, :removetag actions << Action.new(option, argument.dup) when :addtag, :settag raise 'Insufficient argument.' unless argument.include?('=') actions << Action.new(option, *argument.split('=', 2)) when :generate, :rename - actions << Action.new(option, scheme) + actions << Action.new(option, options[:scheme]) else actions << Action.new(option) end @@ -479,7 +478,7 @@ elsif ARGV.empty? exit end -if options.include?(:nocolour) +if options[:nocolour] module Output @colour = false end @@ -493,7 +492,7 @@ ARGV.each do |filename| datum.execute(action) end - datum.save unless options.include?(:pretend) + datum.save unless options[:pretend] rescue RuntimeError => message $stderr.puts $0 + ': ' + filename + ': ' + message end -- cgit v1.2.3-70-g09d2