# Getopt-Declare 1.31 released as a gem

**URL:** <https://www.ruby-forum.com/t/getopt-declare-1-31-released-as-a-gem/238735>\
**Category:** Ruby\
**Created:** [January 26, 2014, 5:17pm UTC](https://www.ruby-forum.com/t/getopt-declare-1-31-released-as-a-gem/238735 "2014-01-26T17:17:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [January 26, 2014, 5:17pm UTC](https://www.ruby-forum.com/t/getopt-declare-1-31-released-as-a-gem/238735/1 "2014-01-26T17:17:37Z")

</div>

Getopt-Declare, the popular argument parsing library (port from a  
popular Perl library) is now up to v1.31 and fixes warnings in  
ruby2.1.0. And it runs like a speed daemon with it.

You can get it from [rubyforge.net](http://rubyforge.net) or [rubygems.org](http://rubygems.org).

[https://rubygems.org/gems/getopt-declare](https://rubygems.org/gems/getopt-declare)  
[https://rubyforge.org/projects/getoptdeclare](https://rubyforge.org/projects/getoptdeclare)

The big advantage of this library is that it makes argument parsing as  
close as what you see is what you get. For example:

args = Getopt::Declare.new( \<\<‘EOARGS’ )  
General options:  
[tight]  
-e \<f:i\>…\<t:i\> Set expansion factor to specified range  
[requires:]  
{ puts “k = [#{f}…#{t}]” }

```
 -e [<k:n>...] Set expansion factor to <k> (or 2 by default)
                    [required]
                            { k = [2] unless k
                              print "k = [", k.join(','), "]\n"; }

```

-b blen:i Use byte length of   
[excludes: -a +c]  
{ print “byte len: #{blen}\n”; }

… Process files [required] [implies: -a]  
{ print “files: #{file}\n”; }

-a [\<n:n\>] Process all data [except item]  
{ print “proc all\n”; print “except #{n}\n”  
if n }

-fab The fabulous option (is always required 🙂  
[required]  
{ defer { print “fabulous!\n” } }

File creation options:

+c Create file [mutex: +c -a]  
{ print “create: file\n”; }

+d Duplicate file [implies: -a and -b 8]  
This is a second line  
{ print “dup (+d) $file\n”; }  
–dup [ditto] (long form)

-how \<n:i\> Set height to [repeatable]

Garbling options:

-g [seed:i] Garble output with optional seed [requires: +c]  
{ print “garbling with #{seed}\n”; }  
-i Case insensitive garbling [required]  
{ print “insensitive\n”; }  
-s Case sensitive garbling  
-w WaReZ m0De 6aRBL1N6

[mutex: -i -s -w]  
EOARGS
