Skip to content

Instantly share code, notes, and snippets.

@davidrenne
Created December 4, 2012 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrenne/4207799 to your computer and use it in GitHub Desktop.
Save davidrenne/4207799 to your computer and use it in GitHub Desktop.
Parse Command Line Arguments in ruby
if $0 == __FILE__
ARGV.each{|arg|
case arg
when /\A--ruby=(.+)/
$ruby_program = $1
when /\A--matzruby=(.+)/
$matzruby_program = $1
when /\A--opts=(.+)/
$opts = $1
when /\A(-r|--only-ruby)\z/
$rubyonly = true
when /\A(-m|--only-matzruby)\z/
$matzrubyonly = true
end
}
ARGV.delete_if{|arg|
/\A-/ =~ arg
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment