the all-thing | 2010-09-04 17:04:08 -0400 ========================================== Trollop 1.11 released --------------------- Date: January 29, 2009 10:03pm Author: William Morgan Labels: trollop, releases URL: http://all-thing.net/old27.txt Trollop 1.11 has been released. This is a minor release with only one new feature: when an option @@ is actually given on the commandline, a new key @_given@ is inserted into the return hash (in addition to @@ being set to the actual argument(s) specified). This allows you to detect which options were actually specified on the commandline. This is necessary for situations where you want one option to override or somehow influence other options. For example, configure's @--exec-prefix@ and @--bindir@ flags: if @--exec-prefix@ is specified, you want to override the default value for @--bindir@, unless that's also given. If neither are given, you want to use the default values. This should be a backwards-compatible release, except for namespace issues, if you actually had options called @-given@. Replies -------- Martin Elzen, on March 8, 2009 3:36pm: ["| \n"] William Morgan, on March 10, 2009 3:24pm: [" | Did you mean to say something? Your email was blank.\n", " | \n"] Martin Elzen, on March 12, 2009 11:33pm: ["| Hi, yes I *did* write an email, guess Firefox 'ate' it, so I'm using Safari\n", "| for this.... I don't remember exactly what I wrote, but I'll do my best to\n", "| remember. First issue I had after running that \"gem install trollop\" (or\n", "| something like) line in a Dos prompt shell on Vista is that entering 'ri\n", "| Trollop' returns 'Nothing known about Trollop'... Even though the gem install\n", "| program did not report any problems... So I'm glad the docs are available\n", "| online. 2nd issue: the line \" require 'trollop' \" in a Ruby script resulted in\n", "| an error, don't remember which now (this was solved by manually copying\n", "| trollop.rb to c:\\Ruby\\lib\\1.8 (or something close to that) ) 3rd issue: could\n", "| you make a correct example on how to call the parse method by hand? I tried\n", "| the following:require 'trollop' parser = Trollop::Parser opts =\n", "| parser.parse(ARGV) do opt :monkey, \"Use monkey mode\" # a\n", "| flag --monkey, defaulting to false opt :goat, \"Use goat mode\", :default =>\n", "| true # a flag --goat, defaulting to true opt :num_limbs, \"Number of\n", "| limbs\", :default => 4 # an integer --num-limbs , defaulting to 4 opt\n", "| :num_thumbs, \"Number of thumbs\", :type => :int # an integer --num-thumbs ,\n", "| defaulting to nilend p opts # returns a hash: { :monkey => false, :goat =>\n", "| true, :num_limbs => 4, :num_thumbs => nil } but Ruby (most recent 1.8.6 RC2 1\n", "| click installer version) then says: 'undefined method 'parse' for\n", "| Trollop::Parser::Class' and I'm not seeing the mistake I'm making... 4th and\n", "| last: is there a way to get Trollop to simply return the options it doesn't\n", "| recognize? I certainly don't want an exception to be raised for that,since\n", "| I've been taught that exceptions should only be used for 'exceptional\n", "| circumstances', and typo's don't seem that exceptional for me (this issue is a\n", "| bit moot for me now, since I began to roll my own after neither getlongopts,\n", "| nor optparse nor Trollop seemed to fit my bill close enough,but might be handy\n", "| for others who also want their option parser to stay out of the way...)\n", "| \n", "| \n"] William Morgan, on March 13, 2009 9:00pm: [" | \n", " | These two sound like gem installation issues.\n", " | \n", " | \n", " | You need something like:\n", " | \n", " | \n", " | parser = Trollop::Parser.new do\n", " | opt :monkey, \"User monkey mode\"\n", " | end\n", " | \n", " | opts = parser.parse ARGV\n", " | \n", " | \n", " | \n", " | No. You could do something with @stop_on_unknown@, maybe, but it would be\n", " | ugly. Exceptions are the right approach here.\n", " | \n"] This delicious text version served up by Whisper .