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