No commit activity in last 3 years
No release in over 3 years
a partial reimplementation of OptionParser
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

optparse-simple¶ ↑

A partial pre-implementation of OptionParser, in particular that actual parsing part:

opts = OptionParser.new do |opts|
  opts.on('-f', '--foo'){ ... }
end

opts.parse! args

I really love optparse but:

  • I don’t care about separators / banners / etc, I use other gems/libraries for that stuff

  • optparse is a PITA to extend and the source code is 1,791 lines long!

This is a re-implementation of the part of optparse that actually parses.

This is not trying to be a whole framework for creating CLI applications. There are already numerous great tools out there. Unfortunately, many of them re-implement OptionParser, themselves, because there’s no library out there (that I know of) that just does the parsing part.

Our libraries need to be more UNIX-y! “Write programs that do one thing and do it well.”

install¶ ↑

sudo gem install remi-optparse-simple -s http://gems.github.com

usage¶ ↑

opts = OptParseSimple.new do |opts|
  opts.on('-f', '--foo'){ ... }
end

opts.parse! args

OptParseSimple is pretty much API-compatible with OptionParser, so far as basic parsing is concerned.

The primary difference at the moment is that OptParseSimple doesn’t raise an exception if #parse or #parse! is called and an invalid option is detected. To raise this exception, enable compatibility mode:

OptParseSimple.compatibility_mode = true

Not much else has been implemented YET