MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / writeToStream

Method writeToStream

extlibs/catch/include/catch/catch.hpp:9219–9258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9217 }
9218
9219 void writeToStream( std::ostream &os ) const {
9220 if (!m_exeName.name().empty()) {
9221 os << "usage:\n" << " " << m_exeName.name() << " ";
9222 bool required = true, first = true;
9223 for( auto const &arg : m_args ) {
9224 if (first)
9225 first = false;
9226 else
9227 os << " ";
9228 if( arg.isOptional() && required ) {
9229 os << "[";
9230 required = false;
9231 }
9232 os << "<" << arg.hint() << ">";
9233 if( arg.cardinality() == 0 )
9234 os << " ... ";
9235 }
9236 if( !required )
9237 os << "]";
9238 if( !m_options.empty() )
9239 os << " options";
9240 os << "\n\nwhere options are:" << std::endl;
9241 }
9242
9243 auto rows = getHelpColumns();
9244 size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;
9245 size_t optWidth = 0;
9246 for( auto const &cols : rows )
9247 optWidth = (std::max)(optWidth, cols.left.size() + 2);
9248
9249 optWidth = (std::min)(optWidth, consoleWidth/2);
9250
9251 for( auto const &cols : rows ) {
9252 auto row =
9253 TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) +
9254 TextFlow::Spacer(4) +
9255 TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth );
9256 os << row << std::endl;
9257 }
9258 }
9259
9260 friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& {
9261 parser.writeToStream( os );

Callers 1

operator<<Method · 0.80

Calls 10

ColumnClass · 0.85
SpacerClass · 0.85
isOptionalMethod · 0.80
emptyMethod · 0.45
nameMethod · 0.45
hintMethod · 0.45
cardinalityMethod · 0.45
sizeMethod · 0.45
indentMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected