M
Massimiliano Mirra - bard
I have a command line program invoked like this:
$ prog --host localhost --port 8000 login --password secret
$ prog --host localhost --port 8000 list --open
....and so on. In other words:
$ command [general options] subcommand [specific options]
Like darcs or cvs.
So far I've been doing fine with getoptlong:
while ARGV.first =~ /^-/
opt, arg = opts.get
case opt
when "--host"
config["host"] = arg
when "--port"
config["port"] = arg.to_i
end
end
When the loop sees the first thing that does not begin with `-'
(option arguments don't count, they get eaten by opts.get), it assumes
it to be the subcommand, and leaves ARGV alone from that point on.
ARGV is later emptied by the subcommand specific options parsing.
I'd like to migrate to optparse, though. But how can I stop argument
parsing at a certain point in optparse?
Massimiliano
$ prog --host localhost --port 8000 login --password secret
$ prog --host localhost --port 8000 list --open
....and so on. In other words:
$ command [general options] subcommand [specific options]
Like darcs or cvs.
So far I've been doing fine with getoptlong:
while ARGV.first =~ /^-/
opt, arg = opts.get
case opt
when "--host"
config["host"] = arg
when "--port"
config["port"] = arg.to_i
end
end
When the loop sees the first thing that does not begin with `-'
(option arguments don't count, they get eaten by opts.get), it assumes
it to be the subcommand, and leaves ARGV alone from that point on.
ARGV is later emptied by the subcommand specific options parsing.
I'd like to migrate to optparse, though. But how can I stop argument
parsing at a certain point in optparse?
Massimiliano