MCPcopy Create free account
hub / github.com/FidoProject/Fido / optUsage

Method optUsage

tests/catch.h:4414–4437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4412 }
4413
4414 void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
4415 typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
4416 std::size_t maxWidth = 0;
4417 for( it = itBegin; it != itEnd; ++it )
4418 maxWidth = (std::max)( maxWidth, it->commands().size() );
4419
4420 for( it = itBegin; it != itEnd; ++it ) {
4421 Detail::Text usage( it->commands(), Detail::TextAttributes()
4422 .setWidth( maxWidth+indent )
4423 .setIndent( indent ) );
4424 Detail::Text desc( it->description, Detail::TextAttributes()
4425 .setWidth( width - maxWidth - 3 ) );
4426
4427 for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
4428 std::string usageCol = i < usage.size() ? usage[i] : "";
4429 os << usageCol;
4430
4431 if( i < desc.size() && !desc[i].empty() )
4432 os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
4433 << desc[i];
4434 os << "\n";
4435 }
4436 }
4437 }
4438 std::string optUsage() const {
4439 std::ostringstream oss;
4440 optUsage( oss );

Callers

nothing calls this directly

Calls 6

TextAttributesClass · 0.85
beginMethod · 0.80
endMethod · 0.80
commandsMethod · 0.80
emptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected