Closed yegor256 closed 3 months ago
There are two ways to do this. The one that is simplest is to set multiple: true
:
require 'gli'
include GLI::App
command :bar do |c|
→ c.flag([:foo], multiple: true)
c.action do |global, options, args|
p options
end
end
run(["bar", "--foo", "first", "--foo", "second"])
That said, what you have should work with comma-delimited arguments, due the use of type: Array
. For me,
run(["bar", "--foo", "first,second"])
# {"foo"=>["first", "second"], :foo=>["first", "second"]}
@davetron5000 it works! your library is awesome (I'm migrating from slop
)
Thanks! Let me know how things go - I haven't been doing many updates as it's generally stable, but I'm still around to support it.
Thanks for your library, it's amazing! Now, the problem. I'm doing this:
I'm getting (the
--foo first
is lost 👎 ):Instead, I would expect:
This is what I'm getting, when I change the last line to:
I believe, it's a normal practice to pass options in command line by using the same flag multiple times. Joining values with a comma may be a good practice too, but not always suitable.
Maybe I missed some configuration option for this particular behavior?