You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ...
* `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)?
The text was updated successfully, but these errors were encountered:
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 correspondingfloat 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:
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)?
The text was updated successfully, but these errors were encountered: