Ruby Command-Line Arguments
If you’re writing a serious Ruby application (not a Rails application necessarily), this question may apply to you: how do you access command-line arguments in Ruby?
Ruby provides an array called ARGV (all upper-case). This array contains all the command-line arguments; so if you run this:
ruby script.rb first second third
… then ARGV.length is 3, ARGV[0] is “first”, ARGV[1] is second, and ARGV[2] is third.
About Ashiq Alibhai
Ashiq Alibhai, PMP, has been a Rails aficionado since 2007, and developed web applications since early 2003, where he learned PHP in one summer. As the driving-force behind RailsRocket and the Launchpad project, he seeks to share the ease of development with Rails far and wide.
This entry was posted in
Development and tagged
command-line,
environment,
ruby. Bookmark the
permalink.
thx to write this.