OptionParser with the potential for endless arguments

I’m writing a ruby script that will take a number of video and audio tracks, run a transcode job on them and monitor the progress. This is going to be called by the command line and the arguments will look like this:

--V1 /path/to/video_file_1.mxf --A1 /path/to/audio_file_1.mxf --A2 /path/to/audio_file_2.mxf

Right now I’m using OptionParser as such:

opts.on("--V1 X") do |video_track|
 options.video_tracks << VideoTrack.new({ :track => 1, :path => video_track })
end
opts.on("--A1 X") do |audio_track|
 options.audio_tracks << AudioTrack.new({ :track => 1, :path => audio_track })
end

This obviously is ridiculous because I’ll need to have a case for each potential track.

Ideally I would like to be able to regex the flags so that I don’t need so many cases. I’ve looked at the documentation and tried several things but I’ve had no luck. Could anyone help a guy out?

Have you tried thor. Not sure if it does what you want, but it is cool.

(in the microsoft paper clip voice) It looks like your using capital letters and numbers for your flags. Would you like to know about a website I use to write simple regex stuff? http://www.rubular.com/
it isn’t pretty but the following regex will grab a dash, any caps letters A-Z, and any digits
/ -+[A-Z]\d/

edit:
(the plus grabs 1 or more of the - flags)
and I tested it by throwing random characters in your dir paths and it seems like it will only evaluate if it starts with a -

you could do /--/ instead of /-+/which will only grab flags that start with --.