1
0
forked from Alepha/Alepha

Make the underlying streambuf private in stacks.

This commit is contained in:
2024-04-03 15:01:52 -04:00
parent 8250680e6c
commit d8689b85e8
5 changed files with 55 additions and 24 deletions

View File

@ -10,6 +10,7 @@ static_assert( __cplusplus > 2020'99 );
#include <Alepha/AutoRAII.h>
#include <Alepha/error.h>
#include <Alepha/Utility/StaticValue.h>
#include <Alepha/System/programName.h>
@ -132,13 +133,13 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
namespace
{
std::string
buildIncompatibleHelpText( const std::string &name, const auto &domains, const auto &exclusivityMembers )
void
incompatibleHelpText( std::ostream &out, const std::string &name, const auto &domains, const auto &exclusivityMembers )
{
if( not domains.contains( typeid( ExclusivityDomain ) )
or domains.at( typeid( ExclusivityDomain ) ).empty() )
{
return "";
return;
}
std::set< std::string > incompatibles;
@ -150,18 +151,17 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
[]( const auto &item ) { return item.second; } );
}
incompatibles.erase( name );
if( incompatibles.empty() ) return "";
std::ostringstream oss;
oss << "\nIncompatible with: \n\n";
if( incompatibles.empty() ) return;
out << "\nIncompatible with: \n\n";
bool first= true;
for( const auto &incompat: incompatibles )
{
if( not first ) oss << ", ";
if( not first ) out << ", ";
first= false;
oss << '`' << incompat << '`';
out << '`' << incompat << '`';
}
oss << std::endl;
return std::move( oss ).str();
out << std::endl;
}
void
@ -229,7 +229,7 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
std::cout << name << ": " << std::string( padding, ' ' ) << helpText.str() << '\n';
// Append the incompatibility text, when we see mutually-exclusive options.
std::cout << buildIncompatibleHelpText( name, domains, exclusivityMembers );
incompatibleHelpText( std::cout, name, domains, exclusivityMembers );
}