-
Notifications
You must be signed in to change notification settings - Fork 287
Open
Description
Trying to make an inverted flag argument and use store_into. It does not seem to work as expected.
Minimum reproducing example:
#include <argparse/argparse.hpp>
int main(int argc, char* argv[]) {
argparse::ArgumentParser program("cool binary");
bool nicearg = false;
program.add_argument("--deactivate")
.help("Disable BFS-based detector ordering and use geometric orientation")
.default_value(true)
.implicit_value(false)
.store_into(nicearg);
try {
program.parse_args(argc, argv);
} catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return EXIT_FAILURE;
}
std::cout << "got nicearg = " << nicearg << std::endl;
}
Expected behavior: the nicearg should be true by default but false when the flag --deactivate is present. Actual behavior: nicearg is always true.
~/argparse-3.2$ clang++-19 -I include/ main.cc -o main
$ ./main
got nicearg = 1
$ ./main --deactivate
got nicearg = 1
Metadata
Metadata
Assignees
Labels
No labels