the all-thing | 2010-09-04 16:40:18 -0400 ========================================== Trollop 1.10 released --------------------- Date: October 21, 2008 9:33pm Author: William Morgan Labels: releases, trollop URL: http://all-thing.net/old7.txt I released a new version of Trollop [1] with a couple minor but cool updates. The best part is the new @:io@ argument type, which uses @open-uri@ to handle filenames and URIs on the commandline. So you can do something like this: require 'trollop' opts = Trollop::options do opt :source, "Source file (or URI) to print", :type => :io, :required => true end opts[:source].each { |l| puts "> #{l.chomp}" } Also, when trying to detect the terminal size, Trollop now tries to @`stty size`@ before loading curses. This gives better results when running under screen (for some reason curses clears the terminal when initializing under screen). I've also cleaned up the documentation quite a bit, expanding the examples on the main page [2], fixing up the RDoc comments, and generating the RDoc documentation [3] with a modern RDoc, so that things like constants actually get documented. If you're still using OptParse, you should really give Trollop a try. I guarantee you'll write much fewer lines of argument parsing code, and you'll get all sorts of nifty features like help page terminal size detection. [1] http://trollop.rubyforge.org/ [2] http://trollop.rubyforge.org/ [3] http://trollop.rubyforge.org/trollop/ Replies -------- quatauta, on October 29, 2008 4:39am: ["| Hi,\n", "| \n", "| started using Trollop yesterday, I really like it.\n", "| \n", "| I realized one difference to Optparse in the parser and I don't know if it is\n", "| intentional: It seems impossible to give a short option and its parameter as\n", "| one argument.\n", "| \n", "| Example:\n", "| \n", "| \n", "| require \"trollop\"\n", "| require \"pp\"\n", "| \n", "| def a(*args)\n", "| opts = Trollop::options(args) do\n", "| opt :aaa, \"Test\", :type => :string\n", "| end\n", "| pp opts\n", "| end\n", "| \n", "| puts \":: Two args\"\n", "| a(\"-a\", \"1\")\n", "| puts \":: Combined in one arg:\"\n", "| a(\"-a1\")\n", "| \n", "| Calling this:\n", "| \n", "| \n", "| :: Two args:\n", "| {:aaa=>\"1\", :help=>false}\n", "| :: Combined in one arg:\n", "| Error: unknown argument \"-1\".\n", "| Try --help for help.\n", "| \n", "| \n"] William, on October 29, 2008 11:16am: ["| \n", "| Weird, I didn't know Optparse supported something like that. I've never seen\n", "| that syntax before.\n", "| \n", "| Supporting it would conflict with Trollop's short option bundling, e.g.\n", "| Trollop allows \"-p -e\" to be written as \"-pe\". Since that's a standard feature\n", "| (e.g. ruby itself!) I'm not eager to interfere with it.\n", "| \n"] Quatauta, on October 29, 2008 11:27am: ["| OK, thanks.\n", "| \n", "| As far as I know, Optparse (and GNU getopt) allows \"-a -b -c 12\" (where -a and\n", "| -b are flags, only -c gets/need a parameter) to be given as \"-abc12\", but not\n", "| \"-c12ab\". Only the last option can take a parameter.\n", "| \n"] William, on October 29, 2008 11:42am: ["| \n", "| Ah, I see. Yes, I would like to support that. Shouldn't be too hard of a\n", "| patch.\n", "| \n", "| Thanks!\n", "| \n"] This delicious text version served up by Whisper .