-1

I am new to ruby and working on a script with command line options.

I need to specify a list of valid input values(String) for a field.

Is there a concise way to do this.

Bo Yuan
  • 107
  • 1
  • 12

1 Answers1

0

If you start with OptionParser then you end up with a list of arguments, and from that you can presume the first is a command.

To validate it you typically do this:

case (command)
when 'action'
  do_action
when 'other'
  do_other
else
  $stderr.puts "#{command.inspect} is not a valid command."
  exit(-1)
end
tadman
  • 208,517
  • 23
  • 234
  • 262