Closed gyagp closed 4 years ago
Sorry about the CI instability. I'll see if any action can be taken there.
Meanwhile, I'd like to make sure if cxxopts is the right choice or not.
The choice of cxxopts is due to limited investigations. For example, here is a post (https://attractivechaos.wordpress.com/2018/08/31/a-survey-of-argument-parsing-libraries-in-c-c/) to compare some of famous alternatives. Some traits I care most and I think suitable for Aquarium are:
To develop such an option parser requires non-trivial effort, which is a reason I hope we don't take at current stage. Google may also care about license, so they'd like to create a new wheel every time. It's not perfect, but a step forward comparing with the very raw way we used before. If we see a better solution in future, we may easily replace it. After all, it's just 1 day effort.
I still have some concerns, is there any security audit for cxxopts? I'd like to minimize the risk of backdoors. Also, I hope such a library can be placed in third_party and managed by DEPS.
@Jiawei-Shao @shaoboyan What's your opinion on this patch?
If this may dismiss some concern from you, Microsoft included cxxopts in vcpkg: https://devblogs.microsoft.com/cppblog/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/
Thanks @hujiajie.
I also don't like the current implementation of command line parser inside Aquarium because right now if we want to add a new command line parameter, we should:
It would be great if we can define the command line parameter, its toggle and its parser together in one place, and generate the usage information directly from this definition instead of writing them separately in different places.
I think we are not using the command line parameters with very complicated formats ("--xxx" and "--xxx=[integer]"), so maybe it is not very hard to write our own command line parameter parser?
To write an option parser from scratch is still a non-trivial task, which may need 1000+ lines of code. To suit our usage, it at least needs to provide following functions:
I think cxxopts already provides all these functions, and I just used a single day to do all the changes. It makes code more robust and maintainable.
@hujiajie thanks. I tend to support this CL. My opinions:
WDYT?
Thanks for the feedback. It sounds the short term plan is to pull in cxxopts, but eventually it will be replaced with our own option parser.
@gyagp Please make cxxopts a third party deps and create a corresponding GN target in //third_party/BUILD.gn.
Thanks for the decision. cxxopts is header file only, so it doesn't need any target in //third_party/BUILD.gn. Please review the new change.
Thanks for the comments. Please take another review!
Thanks for the careful review! PTAL.
LGTM, thanks!
cxxopts (https://github.com/jarro2783/cxxopts) is an open source project as a lightweight C++ option parser. This CL introduces this library (header file only) to better parse the options.