Created
October 22, 2012 18:55
-
-
Save flakyfilibuster/3933375 to your computer and use it in GitHub Desktop.
OptionParser Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'optparse' | |
options = {date: false, sort: false, ddate: false, tag: false, prio: false} | |
optparse = OptionParser.new do|opts| | |
opts.on("--date") do | |
options[:date] = true | |
end | |
opts.on('--sort') do | |
options[:sort] = true | |
end | |
opts.on("--ddate") do | |
options[:ddate] = true | |
end | |
opts.on('--tag') do | |
options[:tag] = true | |
end | |
opts.on('--prio') do | |
options[:prio] = true | |
end | |
end | |
optparse.parse! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have suggestions how to optimize the code or if you notice any glaring errors please contact me :D