mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +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(name.length() >= 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";
|
||||
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) {
|
||||
CLI::App app;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user