| 6312 | } |
| 6313 | |
| 6314 | void writeToStream( std::ostream &os ) const { |
| 6315 | if (!m_exeName.name().empty()) { |
| 6316 | os << "usage:\n" << " " << m_exeName.name() << " "; |
| 6317 | bool required = true, first = true; |
| 6318 | for( auto const &arg : m_args ) { |
| 6319 | if (first) |
| 6320 | first = false; |
| 6321 | else |
| 6322 | os << " "; |
| 6323 | if( arg.isOptional() && required ) { |
| 6324 | os << "["; |
| 6325 | required = false; |
| 6326 | } |
| 6327 | os << "<" << arg.hint() << ">"; |
| 6328 | if( arg.cardinality() == 0 ) |
| 6329 | os << " ... "; |
| 6330 | } |
| 6331 | if( !required ) |
| 6332 | os << "]"; |
| 6333 | if( !m_options.empty() ) |
| 6334 | os << " options"; |
| 6335 | os << "\n\nwhere options are:" << std::endl; |
| 6336 | } |
| 6337 | |
| 6338 | auto rows = getHelpColumns(); |
| 6339 | size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; |
| 6340 | size_t optWidth = 0; |
| 6341 | for( auto const &cols : rows ) |
| 6342 | optWidth = (std::max)(optWidth, cols.left.size() + 2); |
| 6343 | |
| 6344 | optWidth = (std::min)(optWidth, consoleWidth/2); |
| 6345 | |
| 6346 | for( auto const &cols : rows ) { |
| 6347 | auto row = |
| 6348 | TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + |
| 6349 | TextFlow::Spacer(4) + |
| 6350 | TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); |
| 6351 | os << row << std::endl; |
| 6352 | } |
| 6353 | } |
| 6354 | |
| 6355 | friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { |
| 6356 | parser.writeToStream( os ); |
no test coverage detected