From: Robert Klemme Date: 2003-07-19T01:05:06+09:00 Subject: Re: Usage Message for GetoptLong That's a nice coincidence - or a proof for the theory of morphogenetic fields: I was just today wanting to have the same functionality and equally thought how nice it would be to simply have an additional string parameter containing the usage. Hmmm, let's see... I'd override set_options instead of initialize because that is the method douing the work. Try this: class GetoptLong alias old_set_options set_options def set_options(*options) @descriptions = [] @opt_help = "Options:\n" options.each do |arg| if hasDescription? arg @opt_help << sprintf("%-20s: %s\n", arg[0..-3].join( ', ' ), arg.pop ) else @opt_help << arg[0..-2].join( ', ' ) << "\n" end end @opt_help << "\n" old_set_options(*options) end def usage(message="Usage:") puts message puts @opt_help end private def hasDescription?(optarray) case optarray[-1] when GetoptLong::REQUIRED_ARGUMENT, GetoptLong::NO_ARGUMENT, GetoptLong::OPTIONAL_ARGUMENT false else true end end end Regards robert