Project

parseopt

0.0
Low commit activity in last 3 years
No release in over a year
A very simple option parser.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13
 Project Readme

A very simple option parser.

It uses as inspiration Git's internal option parser code, and Ruby's OptionParser.

require 'parseopt'

opts = ParseOpt.new('my command')

# only short
opts.on('b') do |v|
 $bool = v
end

# short and long
opts.on('s', 'string') do |v|
 $string = v
end

# short, long, and help
opts.on('n', 'number', 'Number') do |v|
 $number = v.to_i
end

opts.parse

Running with --help gives:

usage: my command
    -b
    -s, --string
    -n, --number          Number

Installation

Simply install the gem:

gem install parseopt