Closed blysik closed 9 years ago
yup:
main do |*args|
args.each do |hostname|
puts hostname
end
end
arg :hosts, :any, "Hosts to whatever"
It looks at the argument list for the block given to main
and passes only those in, so if you did this:
main do |arg1,arg2|
end
It would set arg1
to hostname
and arg2
to hostname2
, but throw away hostname3
.
So, it's kinda optimized for a fixed-size argument list, but if you use the splat (*args
), it matches everything.
Worked perfectly, thanks! Closing out.
Hi,
I would like to write a CLI tool with an interface like this:
myapp hostname1 hostname2 hostname3
I can do it if I comma separate the values, but I'd really like using spaces. Is this supported somehow? Thanks!