Preferred command line argument parsing library for c++?

Currently CmdStan’s stansummary utility uses stan/io/cmd_line.hpp to parse the command line args.
Could we swap this out with a standard package? either of these:

other suggestions?

I dont have experience with any of them, but if the Boost one is simple to integrate I would go with that, as we already have it included:


I used boost program_options years ago and found it useful at the time. I think I proposed this one a while ago to you and you complained that it does not support the right hierarchical way of handling things… not sure if that still matters.

1 Like

great - will use boost program_options for stansummary

“the right hierarchical way of handling things…” - that’s an oxymoron -
if you can’t do it with some variant of boost program_options, you’re
doing it the wrong way. obligatory xkcd reference:

(the above is strictly my personal opinion - it’s not for me to say what’s right or wrong)


Since you mention xkcd:

It never works in practice; not sure why though…


from a quick read of this gist:
it looks like with a little work (parsing command line twice) - it might be possible to swap out
CmdStan’s arg parser with boost program_options.

1 Like

I’ve used arg_parser:

It’s a bit tough linking in boost program_options, but now that we’re building and linking different runtime libraries, it should be easier.

Is there a reason to change that code? i.e. is there some feature or reduction in code maintenance we’d get by reworking it? If reworking it would get rid of a lot of code then that would be reasonable

working on feature request to add more args to program bin/stansummary -

stansummary uses stan’s src/io/cmd_line.hpp - for maintenance,
it would be better to use a standard, well-documented library.

using boost::program_options instead of CmdStan’s custom argument parser
would get rid of a lot of custom code. it would also allow us to introduce a more
standard command-line interface, which would increase usability.
that’s an issue for another release.