I wrote my own Wake on Lan Script in ruby that uses a Plist to look up
either target Mac address by selected printer or target MAC address by
server and I use option parser for this.
It all works fine if the arguments are input correctly, but if the
arguments are off you get something like this. -x is not declared in my
options and was a test to see how it did when it got something that it
ruby test.rb -x
complete': invalid option: -x (OptionParser::InvalidOption) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1441:incatch’
complete' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1280:inparse_in_order’
catch' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1247:inparse_in_order’
order!' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/optparse.rb:1332:inpermute!’
It’s not the end of the world as if the options are wrong then it won’t
do anything anyway, but I was wondering if anyone could tell me if
there’s any method in the class or extra thing I could do to catch dodgy
arguments and output the help file or the banner rather than this
inelegant list of errors?
Thanks in advance.