NestedCommandLineApp::NestedCommandLineApp(
std::string programName,
std::string version,
+ std::string programHeading,
+ std::string programHelpFooter,
InitFunction initFunction)
- : programName_(std::move(programName)),
- version_(std::move(version)),
- initFunction_(std::move(initFunction)),
- globalOptions_("Global options") {
+ : programName_(std::move(programName)),
+ programHeading_(std::move(programHeading)),
+ programHelpFooter_(std::move(programHelpFooter)),
+ version_(std::move(version)),
+ initFunction_(std::move(initFunction)),
+ globalOptions_("Global options") {
addCommand("help", "[command]",
"Display help (globally or for a given command)",
"Displays help (globally or for a given command).",
if (args.empty()) {
// General help
printf(
- "Usage: %s [global_options...] <command> [command_options...] "
- "[command_args...]\n\n", programName_.c_str());
+ "%s\nUsage: %s [global_options...] <command> [command_options...] "
+ "[command_args...]\n\n",
+ programHeading_.c_str(),
+ programName_.c_str());
std::cout << globalOptions_;
printf("\nAvailable commands:\n");
int(maxLen), p.first.c_str(), resolveAlias(p.second).c_str());
}
}
+ std::cout << "\n" << programHelpFooter_ << "\n";
} else {
// Help for a given command
auto& p = findCommand(args.front());
info.argStr.empty() ? "" : " ",
info.argStr.c_str());
+ printf("%s\n", info.fullHelp.c_str());
+
std::cout << globalOptions_;
if (!info.options.options().empty()) {
printf("\n");
std::cout << info.options;
}
-
- printf("\n%s\n", info.fullHelp.c_str());
}
}