Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

multiple values without repeating the switch

Help
2005-01-20
2013-05-28
  • Anthony Cramp
    Anthony Cramp
    2005-01-20

    Is it possible to supply multiple values to a single switch instance. Ie, instead of requiring

    -L /a/b -L /a/c -L /a/d

    allow

    -L /a/b /a/c /a/d

    parsing the values would stop at the next switch or end of input.

     
    • Mike Smoot
      Mike Smoot
      2005-01-20

      Yup, this is something that has been (privately) discussed in the past.  We'll try and get it into the next release.

      Mike

       
    • Mike Smoot
      Mike Smoot
      2005-01-24

      The problem with this is that if a MultiArg is followed by an Unlabeled arg, then there is no way to know when one ends and the other begins.

      One possibility is to provide an option that allows multiple values for one flag and disallows Unlabeled args. 

      No promises on getting this into the next release.

       
      • slavenya
        slavenya
        2006-10-22

        Are there any updates for this feature?
        It's really important one for me.

         
    • Mike Smoot
      Mike Smoot
      2006-10-23

      Sorry, this feature has not been "officially" added and I don't foresee doing so any time soon.  That said, there is some code, currently commented out, in MultiArg.h (lines 436-442) that looks like it accomplishes what you want.  You might consider uncommenting that code and giving it a try.  Of course, this code obviously hasn't been tested and I can't promise that it won't cause things to explode.  I guarantee that it will cause problems if you're using unlabeled args.

      Let me know if you have any success with this.  Good luck!

       
    • You said "the problem with this is that if a MultiArg is followed by an Unlabeled arg, then there is no way to know when one ends and the other begins" but I think there might be a way. If parsing of a MultiArg ends at end of line or when the next "-" is found then the unlabelled (sic) args are ones left over after such parsing ends. The ancient Prime Computers (remember those?) used to do command line handling in this way (using their cl$pix routine for anyone old enough to be interested in such things). This did require at least two parsings of the command line (all done internally within cl$pix). What TCLAP calls Unlabeled, Prime would call "unclaimed". This wouldn't exactly be trivial, I admit.

      Regards,

      Andrew Marlow