mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-05 06:33:52 +00:00
Better support for subcommand help
This commit is contained in:
parent
34b92f6894
commit
c028ca298d
@ -573,7 +573,7 @@ public:
|
||||
/// The first half of the help print, name plus default, etc
|
||||
std::string help_name() const {
|
||||
std::stringstream out;
|
||||
out << get_name();
|
||||
out << get_name();
|
||||
if(expected() != 0) {
|
||||
if(typeval != "")
|
||||
out << " " << typeval;
|
||||
@ -1170,8 +1170,8 @@ public:
|
||||
for(std::unique_ptr<App> &com : subcommands) {
|
||||
if(com->name == args.back()){
|
||||
args.pop_back();
|
||||
com->parse(args);
|
||||
subcommand = com.get();
|
||||
com->parse(args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1313,12 +1313,19 @@ public:
|
||||
throw OptionNotFound(name);
|
||||
}
|
||||
|
||||
std::string help(size_t wid=30) const {
|
||||
std::string help(size_t wid=30, std::string prev="") const {
|
||||
// Delegate to subcommand if needed
|
||||
if(prev == "")
|
||||
prev = progname;
|
||||
else
|
||||
prev += " " + name;
|
||||
|
||||
if(subcommand != nullptr)
|
||||
return subcommand->help(wid, prev);
|
||||
|
||||
std::stringstream out;
|
||||
if(name != "")
|
||||
out << "Subcommand: " << name << " ";
|
||||
out << prog_discription << std::endl;
|
||||
out << "Usage: " << progname;
|
||||
out << "Usage: " << prev;
|
||||
|
||||
// Check for options
|
||||
bool npos = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user