Parsing multiple composite arguments in clap

Hello there, I'd like one subcommand to parse some input containing a list of key-value pairs. The thing is that I'd like the value to be one of an hex value or a path. Example help:

command <address> {<file>|--val <value>} [<address> {<file>|--val <value>} [...]]

So, the user can use the following command:

command 0x123abc config.bin 0xabc123 --val 0xaaabbb

And I would be able to have a Vec<(u32, Value)>, where Value would be an enum u32|PathBuf.

How can I do something similar with clap? It doesn't need to be exactly like that, but I would like to have a similar functionality. I could use two lists, one being --addresses=addr1,addr2... and another one being --vals=config.bin,0xaaabbb..., but it might be more difficult to parse.

2 Likes