cxxopts
cxxopts copied to clipboard
Parse argument function changes the argc value
The parse function below reset the argc value to one.
https://github.com/jarro2783/cxxopts/blob/b0f67a06de3446aa97a4943ad0ad6086460b2b61/include/cxxopts.hpp#L1333-L1334
That function should not change that value, which is out of expectation.
I make it a backup. The function doesn't change argv.
@nineKnight
Thanks. The reason for me to come up with this question is that I want my program to also print out help if there is no option provided.
I try to check if the argc is 0 or not but I found that after the parse function is called. That value gets updated to 0. It means that I need to check the argc before that call. That is unexpected as I think it should not be too difficult to avoid updating that value.
Get into the source code, maybe @jarro2783 wanna return the number of args that haven't handled, but the function has already made to returns ParserResult
. You can refer to src/example.cpp
.
But I think @jarro2783 can make it work better.
I do plan to get to this. See #123.