mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 14:44:40 +00:00
Merge pull request #393 from rouault/single_arg_larger_than_max_width
usage(): do not emit blank line when a single argument exceeds set_usage_max_line_width()
This commit is contained in:
commit
3a43e75367
@ -2128,7 +2128,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_mutex = arg_mutex;
|
cur_mutex = arg_mutex;
|
||||||
if (curline.size() + 1 + arg_inline_usage.size() >
|
if (curline.size() != indent_size &&
|
||||||
|
curline.size() + 1 + arg_inline_usage.size() >
|
||||||
this->m_usage_max_line_width) {
|
this->m_usage_max_line_width) {
|
||||||
stream << curline << std::endl;
|
stream << curline << std::endl;
|
||||||
curline = std::string(indent_size, ' ');
|
curline = std::string(indent_size, ' ');
|
||||||
|
@ -244,3 +244,13 @@ TEST_CASE("multiline usage, break on mutex") {
|
|||||||
" [--will-go-on-new-line]\n"
|
" [--will-go-on-new-line]\n"
|
||||||
" [--on-a-dedicated-line]");
|
" [--on-a-dedicated-line]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("multiline usage, single arg that is larger than the max width") {
|
||||||
|
argparse::ArgumentParser program("program");
|
||||||
|
program.set_usage_max_line_width(80);
|
||||||
|
program.add_argument("--lots-of-choices").metavar("<veeeeeeeeeeeeeeeeeeeeeeeeeeery_long|veeeeeeeeeeeeeeeeeeeery_long2>");
|
||||||
|
// std::cout << "DEBUG:" << program.usage() << std::endl;
|
||||||
|
REQUIRE(program.usage() ==
|
||||||
|
"Usage: program [--help] [--version]\n"
|
||||||
|
" [--lots-of-choices <veeeeeeeeeeeeeeeeeeeeeeeeeeery_long|veeeeeeeeeeeeeeeeeeeery_long2>]");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user