Created
April 29, 2012 19:37
-
-
Save nuke99/2552889 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'optparse' | |
options = {} | |
$name = nil | |
$age = nil | |
optparse = OptionParser.new do|opts| | |
opts.on( '-h', '--help', 'Display this screen' ) do | |
puts opts | |
exit | |
end | |
opts.on('-n', '--name', 'This is for name') do | |
if ARGV[0] | |
$name = ARGV[0] | |
puts "Name #{$name}" | |
else | |
puts "Please Enter a name" | |
end | |
end | |
opts.on('-a', '--age', 'Age') do | |
if $name | |
#puts $name | |
$age = ARGV[0] | |
puts "Your Age is #{$age}" | |
else | |
puts "Please Enter Name 1st, use -h for information" | |
end | |
end | |
end | |
optparse.parse! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment