On Oct 19, 2007, at 9:41 PM, Peñá, Botp wrote: > From: ara.t.howard [mailto:ara.t.howard / gmail.com] > # def run > # print usage.to_s > > arggh, i did not try the to_s :) > thanks > > # exit > # end > # the reason that the 'to_s' is required is that the usage returns and > # object that inherits from array and ruby treats 'puts an_array' > # specially. i should changed that in the next version... regardless > # 'usage.to_s' will continue to work. > > no problem, ara. The usage.to_s is good enough. great. in 2.1.0 (on rubyforge now) you can just use 'help!' which calls 'print usage.to_s; exit' for you. i'll rework the Usage class to be and Array delegate rather than an Array subclass soon. it annoys me that 'puts usage' does not work... > > > # i'd be interested to see what you come up with for an auto usage > # message - that part was very hard for me and i'm not sure > # mine is the > # best. > # > > no, the automessage part is fine. > my plan really is to add more info on --help and i was looking > where to add more :) > > eg, i want to add sections like "other info", "gotchas", > "copyright", "reporting bugs", and "see also". > oh. the Usage class is already setup to do that. simply do usage['gotchas'] = huge_block_of_text and it will automatically be included in a nicely formatted way. > > > # glad you are using it, and the feedback is really welcome - it's > # surprisingly difficult to get this working smoothly for even > # a modest > # sample of command line apps - there are a lot of variables! ;-) > # > # look for main-2.0.1 later today... > > > it's working great. really. my suggestions were purely cosmetics. > and btw, the new mode option is cool. > many thanks again. > > kind regards -botp > glad to hear it - 2.1.0 also addresses your error handling issue: cfp:~/src/ruby/main/main-2.1.0 > cat a.rb require 'main' puts Main.version Main { argument 'x' do error :before do puts 'this fires *before* normal error handling using #instance_eval...' end error do puts 'this fires *instead of* normal error handling using #instance_eval...' end error :after do puts 'this fires *after* normal error handling using #instance_eval...' end end run(){ p param['x'].given? } } cfp:~/src/ruby/main/main-2.1.0 > ruby -I lib a.rb 2.1.0 this fires *before* normal error handling using #instance_eval... this fires *instead of* normal error handling using #instance_eval... this fires *after* normal error handling using #instance_eval... in fact, 2.1.0 allows *any* exception to specify it's own error handlers - check out lib/main/base.rb and grep for 'handler'. kind regards. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama