#7 define a callback value option

open
nobody
None
5
2013-09-16
2013-09-06
Tom Browder
No

it would be handy to have a callback value option so that, e.g., the '--help' option could call a 'long_help' function instead of returning a string

Discussion

  • Mike Smoot

    Mike Smoot - 2013-09-10

    Can you provide an example, maybe what you'd like the API to look like and an example of what a function might do?

     
  • Tom Browder

    Tom Browder - 2013-09-10

    Possible API:

    TCLAP::SwitchArg h_arg("?",              // short option char
                           "long-help",      // long option name, if any
                           "Extended help.", // short description string
                           cmd,              // add to 'cmd' object
                           &long_help);      // call-back function
    

    When the '-?' or '--long-help' is found on the command line, TCLAP calls the function 'long_help' and exits. The long_help func might look something like this:

    void long_help() 
    { 
      printf("This is the first line of many lines of examples and\n"
             "details.\n");
      // ....
      // ... maybe output an example file...
      // and tell the user about it:
      printf("See example file 'example.dat'.\n");
      // program exits after return from this function
    }
    
     
  • Tom Browder

    Tom Browder - 2013-09-16

    I think I can do the desired thing with a Visitor, so I consider this request closed.

    Thanks.

     

Log in to post a comment.