Last active
December 31, 2015 05:19
-
-
Save postmodern/7939687 to your computer and use it in GitHub Desktop.
Experiment to see if OptionParser allows options to define other options. Turns out you can!
This file contains 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 = OptionParser.new("usage: #{$0}") do |opts| | |
opts.on('-f','--file FILE','loads a file') do |file| | |
puts "loading file #{file}" | |
opts.separator "#{file} options:" | |
opts.on('-c','--custom') do | |
puts "custom option defined by file #{file}" | |
end | |
end | |
end | |
options.parse(ARGV) |
Author
postmodern
commented
Dec 13, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment