Support for default int/float/string values?
sdaau opened this issue · 1 comments
Thanks for a great library!
I was just wondering, how could I implement default values easily?
That is, if --myoption
argument is not specified on the command line, then, say, the corresponding float myoption
in C code gets the value (for example) 5.0 ...
I have seen in the code https://github.com/cofyc/argparse/blob/master/argparse.h, the last three arguments to the macros are:
* `callback`:
* function is called when corresponding argument is parsed.
*
* `data`:
* associated data. Callbacks can use it like they want.
*
* `flags`:
* option flags.
So, I guess, I'd have to implement a custom callback for all such options, and then assign data in the callback, in case the command line argument was not found on the command line. But then, I'm not sure how could I check in the callback, whether the command line argument was present or not?
Is there an example that shows such usage (with default values for arguments, if they are not set on the command line)?