bfgroup / Lyra

A simple to use, composable, command line parser for C++ 11 and beyond
https://bfgroup.github.io/Lyra/
Boost Software License 1.0
471 stars 56 forks source link

Printing help text without ostream #50

Closed vadz closed 1 year ago

vadz commented 3 years ago

It would be nice if it were possible to print the help text without passing by std::ostream, e.g. I'm migrating existing code to fmt, but still have to use either std::cerr or std::ostrstream to be able to print help message and I'd rather avoid it.

The simplest fix would seem to be to refactor parser::print_help_text() to use get_help_text() returning a std::string, as this function doesn't really use any of the streams functionality and does formatting manually anyhow. As usual, I could make a PR if this could be useful -- please let me know.

Note that while this is somewhat related to #46, but not really the same thing.

jjulianoatnv commented 1 year ago

I would benefit. I've been taking the default help text and passing it through a "transformation filter" that modifies the formatting into a structure that the default help text cannot emit. The need to go through an iostream is an annoyance. The proposed change would simplify my post-processing.

jjulianoatnv commented 1 year ago

Nice. https://github.com/bfgroup/Lyra/commit/772e1f039030c0bcbc5b8898f77009812e3b956f looks good, and I believe it will help to improve my use case that I mentioned above.