2

I have a set of rust programs for which the order of arguments is important, e.g.

mytool --foo this --bar that

is not the same as

mytool --bar that --foo this

I'd really like to simply iterate the args from left to right, but clap does an excellent job of abstracting that away.

I'd even be willing to iterate all the args and, using indices_of, generate an ordered Vec of arguments and then process that, but I don't think clap provides a way to iterate all the args in any order. I'll have a rather large set of rather complex command lines, so I'd rather not have to repeat the list of argument names.

I'd like to keep all the great things that clap does, but I really need to know the ordering of the input.

Any advice?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Andy Jewell
  • 413
  • 3
  • 12
  • 4
    I think this is an X/Y problem. If you want the args to be ordered why use flags? Anyway, are arguments depending on the previous ones? – Netwave Oct 16 '21 at 15:57
  • Yes, some arguments are depending on previous ones. Sometimes it's more like formatting options -- print one of these then some of those then two other things. I need flags because there are many flags, each of which are optional and can be repeated, and affect the things to the right. – Andy Jewell Oct 16 '21 at 17:53
  • 2
    I think you may want to take a look at subcommands.... – Netwave Oct 17 '21 at 13:59

0 Answers0