argos

A slim command-line parser that does one thing well: turn an array of strings, such as ARGV, into a hash of recognized options and their arguments, leaving unrecognized strings in the original array.

Argos was Odysseus’ faithful dog, who was good at recognizing ;)

Installation

Install as gem:

gem install 'argos'

or simply copy argos.rb into your project’s lib dir.

Synopsis

 require 'argos'

 optdef = {
   "v"   => true,
   "n"   => proc {|arg| Integer(arg)}
 }

 argv = %w{-v -n10 filename}
 opts = Argos.parse_options(argv, optdef)
 p opts    # ==> {"v"=>true, "n"=>10}
 p argv    # ==> ["filename"]

See also example dir.

Features

Limitations

About

Copyright © 2006-2014 Joel VanderWerf, vjoel@users.sourceforge.net.

License is BSD. See COPYING.