-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an extra class Help
or HelpProvider
.
#108
Comments
Idea 1:Provide a virtual class that users could customize. class HelpFormatter {
std::string REQUIRED = "Required";
virtual std::string help_name(Option* opt) {...}
virtual std::string help_opts(Option* opt) {...}
virtual std::string help_desc(Option* opt) {...}
virtual std::string combine_help(Option* opt) {...}
virtual std::string make_group(App* app, std::string name) {...}
virtual std::string make_description(App* app) {...}
virtual std::string make_usage(App* app, std::string name) {...}
virtual std::string make_help(App* app) {...}
virtual std::string make_help_all(App* app) {...} // NEW, exapands groups
} The standard combine help would do:
Hooks could be added for the rest of the formatting, as well, like group names. You would use it like this: class MyHelp : public HelpFormatter {...}
app.set_help_formatter(MyHelp()); It would then be inherited by subcommands. Subclasses of App would also be able to change the default help formatter. |
Idea 2:Add a class that accepts lambda functions (as app.get_help_formatter().set_required_name("(REQUIRED)");
app.get_help_formatter().set_combine_help([](...){...}); |
Idea 3:Add a template formatting language. |
Thanks for putting together this issue! Here are some thoughts on what would be nice to have (copied from the gitter chat):
|
This would allow customization of all components of the help messages; things like localization would be possible.
I like the idea of adding a new class that takes responsibility for the help formatting; even with no changes, this would keep App and Option a bit shorter and cleaner, which is a good thing.
The text was updated successfully, but these errors were encountered: