mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 05:03:52 +00:00
Tighten up syntax from recent PR a bit
This commit is contained in:
parent
1933a21a6d
commit
bd67a953b2
@ -2023,27 +2023,19 @@ namespace FailureMessage {
|
|||||||
|
|
||||||
/// Printout a clean, simple message on error (the default in CLI11 1.5+)
|
/// Printout a clean, simple message on error (the default in CLI11 1.5+)
|
||||||
inline std::string simple(const App *app, const Error &e) {
|
inline std::string simple(const App *app, const Error &e) {
|
||||||
const bool has_help = app->get_help_ptr() != nullptr;
|
|
||||||
const bool has_help_all = app->get_help_all_ptr() != nullptr;
|
|
||||||
|
|
||||||
std::string header = std::string(e.what()) + "\n";
|
std::string header = std::string(e.what()) + "\n";
|
||||||
|
std::vector<std::string> names;
|
||||||
|
|
||||||
if(has_help || has_help_all) {
|
// Collect names
|
||||||
header += "Run with ";
|
if(app->get_help_ptr() != nullptr)
|
||||||
|
names.push_back(app->get_help_ptr()->get_name());
|
||||||
|
|
||||||
if(has_help) {
|
if(app->get_help_all_ptr() != nullptr)
|
||||||
header += app->get_help_ptr()->get_name();
|
names.push_back(app->get_help_all_ptr()->get_name());
|
||||||
}
|
|
||||||
|
|
||||||
if(has_help_all) {
|
// If any names found, suggest those
|
||||||
if(has_help) {
|
if(!names.empty())
|
||||||
header += " or ";
|
header += "Run with " + detail::join(names, " or ") + " for more information.\n";
|
||||||
}
|
|
||||||
header += app->get_help_all_ptr()->get_name();
|
|
||||||
}
|
|
||||||
|
|
||||||
header += " for more information.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user