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¶ ↑
Copyright © 2011 lpm11. See LICENSE.txt for further details.