1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Improved the layout of ConsoleApplication::printHelp() when there are long items

This commit is contained in:
jules 2019-02-13 12:46:00 +00:00
parent b8bee51651
commit 097525ba5b

View file

@ -261,18 +261,29 @@ void ConsoleApplication::printHelp (const String& preamble, const ArgumentList&
.fromLastOccurrenceOf ("\\", false, false);
StringArray namesAndArgs;
int maxLength = 0;
int descriptionIndent = 0;
for (auto& c : commands)
{
auto nameAndArgs = exeName + " " + c.argumentDescription;
namesAndArgs.add (nameAndArgs);
maxLength = std::max (maxLength, nameAndArgs.length());
descriptionIndent = std::max (descriptionIndent, nameAndArgs.length());
}
descriptionIndent = std::min (descriptionIndent + 1, 40);
for (size_t i = 0; i < commands.size(); ++i)
std::cout << " " << namesAndArgs[(int) i].paddedRight (' ', maxLength + 2)
<< commands[i].commandDescription << std::endl;
{
auto nameAndArgs = namesAndArgs[(int) i];
std::cout << ' ';
if (nameAndArgs.length() > descriptionIndent)
std::cout << nameAndArgs << std::endl << String::repeatedString (" ", descriptionIndent + 1);
else
std::cout << nameAndArgs.paddedRight (' ', descriptionIndent);
std::cout << commands[i].commandDescription << std::endl;
}
std::cout << std::endl;
}