48 std::vector< Row > rows;
49 rows.reserve( app.get_options().size() );
51 for (
const auto* opt : app.get_options() )
53 if ( opt->get_name().empty() )
57 r.name = opt->get_name();
58 r.count = std::to_string( opt->count() );
61 if ( opt->count() > 0 )
63 std::ostringstream vals;
64 auto results = opt->results();
65 for (
size_t i = 0; i < results.size(); ++i )
75 r.value =
"(not set)";
79 r.def = opt->get_default_str();
81 rows.push_back( std::move( r ) );
85 size_t w_name = std::max< size_t >( 4, std::max_element( rows.begin(), rows.end(), [](
auto& a,
auto& b ) {
86 return a.name.size() < b.name.size();
88 size_t w_count = std::max< size_t >( 5, std::max_element( rows.begin(), rows.end(), [](
auto& a,
auto& b ) {
89 return a.count.size() < b.count.size();
91 size_t w_value = std::max< size_t >( 5, std::max_element( rows.begin(), rows.end(), [](
auto& a,
auto& b ) {
92 return a.value.size() < b.value.size();
94 size_t w_def = std::max< size_t >( 7, std::max_element( rows.begin(), rows.end(), [](
auto& a,
auto& b ) {
95 return a.def.size() < b.def.size();
99 os << std::left << std::setw( w_name + 2 ) <<
"Name" << std::setw( w_count + 2 ) <<
"Count"
100 << std::setw( w_value + 2 ) <<
"Value"
103 os << std::string( w_name + w_count + w_value + w_def + 8,
'-' ) <<
"\n";
106 for (
const auto& r : rows )
108 os << std::left << std::setw( w_name + 2 ) << r.name << std::setw( w_count + 2 ) << r.count
109 << std::setw( w_value + 2 ) << r.value << r.def <<
"\n";
void print_cli_summary(const CLI::App &app, std::ostream &os=std::cout)
Prints an overview of the available flags, the passed arguments, defaults, etc.
Definition cli11_helper.hpp:38
CLI::Option * add_flag_with_default(CLI::App &app, const std::string &name, bool &field, std::string desc="")
Just a small wrapper to set the default of the flag to the value of the variable where it shall be st...
Definition cli11_helper.hpp:32
CLI::Option * add_option_with_default(CLI::App &app, const std::string &name, auto &field, std::string desc="")
Just a small wrapper to set the default of the option to the value of the variable where it shall be ...
Definition cli11_helper.hpp:20