forked from Alepha/Alepha
AutoRAII based stream adaptors.
This commit is contained in:
@ -195,11 +195,7 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
|
||||
for( const auto &[ name, def ]: programOptions() )
|
||||
{
|
||||
// When turning off wrapping, here, we also emit a newline between entries.
|
||||
AutoRAII wrapping
|
||||
{
|
||||
[&] { std::cout << StartWrap{ width, alignmentWidth }; },
|
||||
[] { std::cout << EndWrap << std::endl; }
|
||||
};
|
||||
auto wrapping= adaptStream( StartWrap{ width, alignmentWidth }, std::cout );
|
||||
|
||||
const auto &[ _, helpText, defaultBuilder, domains ]= def;
|
||||
|
||||
@ -217,11 +213,7 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
|
||||
substitutions[ "canonical-name"s ]= lambaste<=canonicalProgramName.value();
|
||||
}
|
||||
|
||||
AutoRAII substitution
|
||||
{
|
||||
[&]{ std::cout << StartSubstitutions{ '!', substitutions }; },
|
||||
[] { std::cout << EndSubstitutions; }
|
||||
};
|
||||
auto substitution= adaptStream( StartSubstitutions{ '!', substitutions }, std::cout );
|
||||
|
||||
// How much unused of the max width there will be
|
||||
const std::size_t padding= alignmentWidth - name.size() - 2;
|
||||
@ -289,16 +281,8 @@ namespace Alepha::Hydrogen ::detail:: ProgramOptions_m
|
||||
|
||||
if( canonicalName.has_value() ) substitutions[ "canonical-name"s ]= lambaste<=canonicalName.value();
|
||||
|
||||
AutoRAII wrapping
|
||||
{
|
||||
[] { std::cout << StartWrap{ getConsoleWidth() }; },
|
||||
[] { std::cout << EndWrap; }
|
||||
};
|
||||
AutoRAII substitution
|
||||
{
|
||||
[&]{ std::cout << StartSubstitutions{ '!', substitutions }; },
|
||||
[] { std::cout << EndSubstitutions; }
|
||||
};
|
||||
auto wrapping= adaptStream( StartWrap{ getConsoleWidth() }, std::cout );
|
||||
auto substitution= adaptStream( StartSubstitutions{ '!', substitutions }, std::cout );
|
||||
|
||||
std::cout << helpMessage << std::endl << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user