Project

optparshie

0.0
No commit activity in last 3 years
No release in over 3 years
OptionParser with Hashie::Mash like accessibility.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.0.0
>= 1.6.4
>= 2.3.0
 Project Readme

optparshie¶ ↑

Enhanced OptionParser, it can access to parsed argv through Hashie::Mash like.

Example¶ ↑

require("optparshie");

argv = "--exp --wa -a 2 --on ADDITION".split(/\s+/);
puts("test argv: #{argv}");

opt = OptionParshie.new();
opt.on("-a","--a-value=VAL");
opt.on("--exp");
opt.on("-w","--waros");
opt.on("-o","--on");

# parse returns mash
puts("opt.parse => #{opt.parse(argv)}");
# parse! returns [argv, mash]
puts("opt.parse! => #{opt.parse!(argv)}");

# access with short option
puts("opt.a => #{opt.a}");
puts("opt.w => #{opt.w}");
puts("opt.o => #{opt.o}");

# access with long option
puts("opt.a_value => #{opt.a_value}");
puts("opt.exp => #{opt.exp}");
puts("opt.waros => #{opt.waros}");
# Oops! It's already defined method....
# opt.on => Usage: example1 (blah blah blah)

# instead of you can access through hash
puts("opt.mash.on => #{opt.mash.on}");

Copyright © 2011 lpm11. See LICENSE.txt for further details.