mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
nicer usage text for required arg
This commit is contained in:
parent
68fb9f16d8
commit
ed06438faf
@ -529,12 +529,14 @@ public:
|
|||||||
std::copy(std::begin(argument.mNames), std::end(argument.mNames),
|
std::copy(std::begin(argument.mNames), std::end(argument.mNames),
|
||||||
std::ostream_iterator<std::string>(nameStream, " "));
|
std::ostream_iterator<std::string>(nameStream, " "));
|
||||||
stream << nameStream.str() << "\t" << argument.mHelp;
|
stream << nameStream.str() << "\t" << argument.mHelp;
|
||||||
if (argument.mIsRequired && !argument.mDefaultValue.has_value())
|
|
||||||
stream << "[Required]";
|
|
||||||
if (argument.mDefaultValue.has_value()) {
|
if (argument.mDefaultValue.has_value()) {
|
||||||
if (!argument.mHelp.empty())
|
if (!argument.mHelp.empty())
|
||||||
stream << " ";
|
stream << " ";
|
||||||
stream << "[default: " << argument.mDefaultValueRepr << "]";
|
stream << "[default: " << argument.mDefaultValueRepr << "]";
|
||||||
|
} else if (argument.mIsRequired) {
|
||||||
|
if (!argument.mHelp.empty())
|
||||||
|
stream << " ";
|
||||||
|
stream << "[required]";
|
||||||
}
|
}
|
||||||
stream << "\n";
|
stream << "\n";
|
||||||
return stream;
|
return stream;
|
||||||
|
Loading…
Reference in New Issue
Block a user