cxxopts: options.help({}) doesn't show positional arguments sometimes
Code sample:
int main(int argc, char *argv[]) {
try {
cxxopts::Options options(argv[0], "Sample");
options.positional_help("<Extra args>");
options.add_options()
("s,set", "Set whatever.", cxxopts::value<std::vector<std::string>>())
("h,help", "Print help and exit.")
;
options.parse(argc, argv);
options.parse_positional({"file", "remove-label", "set-label"});
// help
if (options.count("help")) {
cout << options.help({""}) << std::endl;
exit(0);
}
} catch (const cxxopts::OptionException& e) {
cout << "error parsing options: " << e.what() << std::endl;
exit(-1);
}
return 0;
}
Expected: Show the “set” option in the help. Actual: Show only “help” option.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 20 (10 by maintainers)
Commits related to this issue
- Allow positional arguments to show in help Fixes #72. This adds an option for positional arguments to be shown in the help output. — committed to jarro2783/cxxopts by jarro2783 7 years ago
Sorry for the inconvenience.
can you try this code please:
It’s happen only with an argument with the name “set-label”. Thanks,