nicer usage text for required arg

This commit is contained in:
Mike Zozu 2020-12-15 23:01:07 +03:00
parent 68fb9f16d8
commit ed06438faf

View File

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