mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
Aligment in multiline description (#269)
This commit is contained in:
parent
b1036a1ad0
commit
ca4bc6a6fc
@ -164,7 +164,12 @@ inline std::ostream &format_help(std::ostream &out, std::string name, std::strin
|
|||||||
if(!description.empty()) {
|
if(!description.empty()) {
|
||||||
if(name.length() >= wid)
|
if(name.length() >= wid)
|
||||||
out << "\n" << std::setw(static_cast<int>(wid)) << "";
|
out << "\n" << std::setw(static_cast<int>(wid)) << "";
|
||||||
out << description;
|
for(const char c : description) {
|
||||||
|
out.put(c);
|
||||||
|
if(c == '\n') {
|
||||||
|
out << std::setw(static_cast<int>(wid)) << "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out << "\n";
|
out << "\n";
|
||||||
return out;
|
return out;
|
||||||
|
@ -470,6 +470,18 @@ TEST(THelp, CustomHelp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(THelp, NextLineShouldBeAlignmentInMultilineDescription) {
|
||||||
|
CLI::App app;
|
||||||
|
int i;
|
||||||
|
const std::string first{"first line"};
|
||||||
|
const std::string second{"second line"};
|
||||||
|
app.add_option("-i,--int", i, first + "\n" + second);
|
||||||
|
|
||||||
|
const std::string help = app.help();
|
||||||
|
const auto width = app.get_formatter()->get_column_width();
|
||||||
|
EXPECT_THAT(help, HasSubstr(first + "\n" + std::string(width, ' ') + second));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(THelp, NiceName) {
|
TEST(THelp, NiceName) {
|
||||||
CLI::App app;
|
CLI::App app;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user