#14 Misleading behaviour of UnlabeledValueArg

closed-fixed
None
5
2009-07-15
2009-02-11
nyrk
No

In the manual is said that "An UnlabeledValueArg is a ValueArg that is not identified by a flag on the command line. Instead UnlabeledValueArgs are identified by their position in the argv array. "
whilst reading the API documentation, seems that the name assigned in the constructor of UnlabeledValueArg can be use as long flag for the positional option:

"name - A one word name for the argument. Can be used as a long flag on the command line. "

At least the API documentation is not compliant with the manual and the constructor of UnlabeledValueArg is misleading.

At the end, it doesn't seem possible to define a positional argument that can be passed trough a prefixed flag.

For instance it is not straightforward obtain the same behaviour for the following CLI arguments:

./myexec input.txt output.txt
and
./myexe --myinputfile input.txt --myoutputfile output.txt

Discussion

  • nyrk

    nyrk - 2009-02-11

    Simple sample of cpp code with positional option

     
  • Mike Smoot

    Mike Smoot - 2009-07-15

    Sorry for the confusion. The API documentation here was indeed incorrect for UnlabeledValueArg (UnlabeledMultiArg had it right). This has now been fixed in CVS.

    Doing what you want isn't possible with *just* UnlabeledValueArgs, however I think you could accomplish this by defining two optional UnlabeledValueArgs and two optional ValueArgs. You'd just have to check manually to determine if both unlabeled args or both labeled args had been set. I suspect the difficulty you'd run into would be when one unlabled arg and one labeled arg get set.

     
  • Mike Smoot

    Mike Smoot - 2009-07-15
    • assigned_to: nobody --> mes5k
    • status: open --> closed-fixed
     

Log in to post a comment.