views:

20

answers:

2

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?

+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
+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