Merge pull request #93 from cekc/nicer-message-for-required

nicer usage text for required arg
This commit is contained in:
Pranav 2020-12-15 15:06:25 -06:00 committed by GitHub
commit 9903a22904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;