Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Minimalistic Ruby option parser (based on OptionParser API)
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
README.rdoc
Rakefile
VERSION.yml
optparse-simple.gemspec

README.rdoc

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

Something went wrong with that request. Please try again.