MCPcopy Create free account
hub / github.com/apache/thrift / optUsage

Method optUsage

compiler/cpp/tests/catch/catch.hpp:4895–4918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4893 }
4894
4895 void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
4896 typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
4897 std::size_t maxWidth = 0;
4898 for( it = itBegin; it != itEnd; ++it )
4899 maxWidth = (std::max)( maxWidth, it->commands().size() );
4900
4901 for( it = itBegin; it != itEnd; ++it ) {
4902 Detail::Text usage( it->commands(), Detail::TextAttributes()
4903 .setWidth( maxWidth+indent )
4904 .setIndent( indent ) );
4905 Detail::Text desc( it->description, Detail::TextAttributes()
4906 .setWidth( width - maxWidth - 3 ) );
4907
4908 for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
4909 std::string usageCol = i < usage.size() ? usage[i] : "";
4910 os << usageCol;
4911
4912 if( i < desc.size() && !desc[i].empty() )
4913 os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
4914 << desc[i];
4915 os << "\n";
4916 }
4917 }
4918 }
4919 std::string optUsage() const {
4920 std::ostringstream oss;
4921 optUsage( oss );

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected