the all-thing | 2010-07-29 19:51:20 -0400 ========================================== Trollop 1.15 released --------------------- Date: September 30, 2009 6:59pm Author: William Morgan Labels: trollop, releases URL: http://all-thing.net/trollop-1.15-released.txt I've just released Trollop [1] 1.15, which fixes an irritating misfeature pointed out by Rafael Sevilla: when Trollop runs out of characters when it's generating short option names, e.g. when you have a lot of options, it shouldn't throw an exception and die. It should just continue peacefully. Trollop's reign of domination [2] continues! [1] http://trollop.rubyforge.org [2] http://stackoverflow.com/questions/897630/really-cheap-command-line-option-parsing-in-ruby/1012930#1012930 Replies -------- Will Fitzgerald, on March 31, 2010 1:53pm: ["| The float option doesn't (yet) handle scientific notation, but it could with\n", "| this diff from the current Git repo. It adds an optional part to the FLOAT_RE,\n", "| and a test at the end. Thanks for Trollop, by the way; it is the best command\n", "| line parser I've ever used:\n", "| \n", "| \n", "| diff --git a/lib/trollop.rb b/lib/trollop.rb\n", "| index 8c8818f..02d4c34 100644\n", "| --- a/lib/trollop.rb\n", "| +++ b/lib/trollop.rb\n", "| @@ -22,7 +22,7 @@ class HelpNeeded StandardError; end\n", "| class VersionNeeded StandardError; end\n", "| \n", "| ## Regex for floating point numbers\n", "| -FLOAT_RE = /^-?((\\d+(\\.\\d+)?)|(\\.\\d+))$/\n", "| +FLOAT_RE = /^-?((\\d+(\\.\\d+)?)|(\\.\\d+))([eE][-+]?[\\d]+)?$/\n", "| \n", "| ## Regex for parameters\n", "| PARAM_RE = /^-(-|\\.$|[^\\d\\.])/\n", "| diff --git a/test/test_trollop.rb b/test/test_trollop.rb\n", "| index ed07a3c..fadfb2a 100644\n", "| --- a/test/test_trollop.rb\n", "| +++ b/test/test_trollop.rb\n", "| @@ -97,6 +97,8 @@ class Trollop ::Test::Unit::TestCase\n", "| assert_equal 2.41, opts[\"argsf\"]\n", "| assert_nothing_raised { opts = @p.parse(%w(--argsf 2)) }\n", "| assert_equal 2, opts[\"argsf\"]\n", "| + assert_nothing_raised { opts = @p.parse(%w(--argsf 1.0e-2)) }\n", "| + assert_equal 1.0e-2, opts[\"argsf\"]\n", "| assert_raise(CommandlineError) { @p.parse(%w(--argsf hello)) }\n", "| \n", "| # single arg: date\n", "| \n", "| \n", "| \n", "| \n", "| \n", "| -- Will\n", "| \n"] William Morgan, on April 20, 2010 2:44am: [" | \n", " | Newest version is 1.16.2 and this is in it. Thanks again!\n"] This delicious text version served up by Whisper .