does anyone here know if clap can parse an argument into a vector of structs with optional fields that would fall back to a default value?

i'm trying to write an interface for forwarding ports like so: [host:]port[:port][,[host:]port[:port]], square brackets denoting optionality with host defaulting to 127.0.0.1

example: $ program -f 3,127.0.0.2:8080:80 would map to something like [ [ 127.0.0.1, 3, 3 ], [ 127.0.0.2, 8080, 80 ] ]

feels like something i'll have to write my own parser for but i just wanna make sure there isn't a better way to do this, wouldn't be suprised if clap can cover such a complex usecase

#rust #rustlang

@v_v by providing custom FromStr implementation for the type?
@tymwol @v_v that or a `value_parser`