Enh rqst: mutator for CmdLine description

  • Andrew Peter Marlow


    Please provide a mutator that allows the description of a CmdLine object to be changed. At the moment I can only set it as the first constructor argument. This string gets printed as part of the usage text but I want my usage text supplemented by material I do not fully know until after the command line usage been parsed. This is because I supply my own -h option rather than using the builtin.

    Maybe there is another way to do what I want, if so please advise. My application is a unit testing framework that takes various arguments followed by a trailing list of test names. I want my usage/help message to say what the allowed test names are.


    Andrew Marlow

    • Mike Smoot

      Mike Smoot - 2006-11-14

      Hi Andrew,

      I think your best bet is to either implement your own CmdLineOutput object or extend an existing one, then use CmdLine::setOutput(yourOut) to apply it.  See test4.cpp in the examples dir of the distribution to see how it's done. 

      That said, I'll consider providing a setMessage method, but my inclination is keep things as they are. The intent of the message is just to provide a short description of the program in question, not a full accounting of it's state.  In you case, I'd expect the message to say something like "My unit test app" and then override StdOutput.h to provide more detail.

      Again, let me know if that doesn't work for you.


    • Andrew Peter Marlow

      That sounds good to me. Thanks for the tip!



Log in to post a comment.