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