0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.