How to parse an argument without a name with Ruby's optparse
Posted
by Leonid Shevtsov
on Stack Overflow
See other posts from Stack Overflow
or by Leonid Shevtsov
Published on 2010-03-15T17:36:43Z
Indexed on
2010/03/15
17:39 UTC
Read the original article
Hit count: 309
I need to parse a command line like
script.rb <mandatory filename> [options]
with optparse.
Sure I can write some custom code to handle the filename, then pass ARGV
to optparse, but maybe there's a simpler way to do it?
EDIT: there's another hacky way to parse such a command line, and that is pass '--mandatory-filename ' + ARGV
to optparse, then handle the --mandatory-filename
option.
© Stack Overflow or respective owner