I am writing a Ruby CLI (Command Line Interface) program and I would like to be able to call subcommands similar to what rails does when you call rails generate ...
or rails server
etc. Can anyone point me in the right direction on how to do this?
views:
20answers:
2
+1
A:
You just need to get the command line arguments and work with those. They are stored in the global array ARGV
:
ARGV.each do|a|
puts "Argv: #{a}"
end
That prints out the arguments sent to the ruby script
NullUserException
2010-09-11 03:24:50
+1
A:
The standard library's OptionParser class exists specifically for handling command-line arguments like this. Here's a tutorial. It should simplify your work considerably.
Jordan
2010-09-11 03:29:45