12#include "../Formatter.hpp" 
   23CLI11_INLINE std::string
 
   25    std::stringstream out;
 
   27    out << 
"\n" << group << 
":\n";
 
   28    for(
const Option *opt : opts) {
 
 
   36    std::vector<const Option *> opts =
 
 
   46    std::stringstream out;
 
   47    std::vector<std::string> groups = app->
get_groups();
 
   50    for(
const std::string &group : groups) {
 
   51        std::vector<const Option *> opts = app->
get_options([app, mode, &group](
const Option *opt) {
 
   54                   && (mode != AppFormatMode::Sub                
 
   58        if(!group.empty() && !opts.empty()) {
 
 
   76        desc += 
" " + 
get_label(
"REQUIRED") + 
" ";
 
   80        if(max_options == min_options) {
 
   81            desc += 
" \n[Exactly " + std::to_string(min_options) + 
" of the following options are required]";
 
   82        } 
else if(max_options > 0) {
 
   83            desc += 
" \n[Between " + std::to_string(min_options) + 
" and " + std::to_string(max_options) +
 
   84                    " of the following options are required]";
 
   86            desc += 
" \n[At least " + std::to_string(min_options) + 
" of the following options are required]";
 
   88    } 
else if(max_options > 0) {
 
   89        desc += 
" \n[At most " + std::to_string(max_options) + 
" of the following options are allowed]";
 
   92    return (!desc.empty()) ? desc + 
"\n\n" : std::string{};
 
 
   98        return usage + 
"\n\n";
 
  101    std::stringstream out;
 
  109    std::vector<std::string> groups = app->
get_groups();
 
  112    std::vector<const Option *> non_pos_options =
 
  114    if(!non_pos_options.empty())
 
  115        out << 
" [" << 
get_label(
"OPTIONS") << 
"]";
 
  121    if(!positionals.empty()) {
 
  123        std::vector<std::string> positional_names(positionals.size());
 
  124        std::transform(positionals.begin(), positionals.end(), positional_names.begin(), [
this](
const Option *opt) {
 
  125            return make_option_usage(opt);
 
  128        out << 
" " << detail::join(positional_names, 
" ");
 
  133               [](
const CLI::App *subc) { return ((!subc->get_disabled()) && (!subc->get_name().empty())); })
 
 
  148        return std::string{};
 
  150    return '\n' + footer + 
'\n';
 
 
  156    if(mode == AppFormatMode::Sub)
 
  159    std::stringstream out;
 
  166        detail::streamOutAsParagraph(
 
  180        out << footer_string;
 
 
  187    std::stringstream out;
 
  192    std::vector<std::string> subcmd_groups_seen;
 
  193    for(
const App *com : subcommands) {
 
  194        if(com->get_name().empty()) {
 
  195            if(!com->get_group().empty() && com->get_group().front() != 
'+') {
 
  200        std::string group_key = com->get_group();
 
  201        if(!group_key.empty() &&
 
  202           std::find_if(subcmd_groups_seen.begin(), subcmd_groups_seen.end(), [&group_key](std::string a) {
 
  203               return detail::to_lower(a) == detail::to_lower(group_key);
 
  204           }) == subcmd_groups_seen.end())
 
  205            subcmd_groups_seen.push_back(group_key);
 
  209    for(
const std::string &group : subcmd_groups_seen) {
 
  210        out << 
'\n' << group << 
":\n";
 
  212            [&group](
const App *sub_app) { 
return detail::to_lower(sub_app->
get_group()) == detail::to_lower(group); });
 
  213        for(
const App *new_com : subcommands_group) {
 
  214            if(new_com->get_name().empty())
 
  216            if(mode != AppFormatMode::All) {
 
  219                out << new_com->help(new_com->get_name(), AppFormatMode::Sub);
 
 
  229    std::stringstream out;
 
  232    out << std::setw(static_cast<int>(
column_width_)) << std::left << name;
 
  233    detail::streamOutAsParagraph(
 
 
  240    std::stringstream out;
 
  244        detail::streamOutAsParagraph(
 
  259    if(mode == AppFormatMode::Sub && !footer_string.empty()) {
 
  262        if(footer_string == parent_footer) {
 
  266    if(!footer_string.empty()) {
 
  270            out << footer_string;
 
 
  277    std::stringstream out;
 
  281        out << std::setw(static_cast<int>(
column_width_)) << std::left << left;
 
  284            bool skipFirstLinePrefix = 
true;
 
  287                skipFirstLinePrefix = 
false;
 
  289            detail::streamOutAsParagraph(
 
  298        const auto names = detail::split(namesCombined, 
',');
 
  299        std::vector<std::string> vshortNames;
 
  300        std::vector<std::string> vlongNames;
 
  301        std::for_each(names.begin(), names.end(), [&vshortNames, &vlongNames](
const std::string &name) {
 
  302            if(name.find(
"--", 0) != std::string::npos)
 
  303                vlongNames.push_back(name);
 
  305                vshortNames.push_back(name);
 
  309        std::string shortNames = detail::join(vshortNames, 
", ");
 
  310        std::string longNames = detail::join(vlongNames, 
", ");
 
  314        const auto shortNamesColumnWidth =
 
  316        const auto longNamesColumnWidth = 
static_cast<int>(
column_width_) - shortNamesColumnWidth;
 
  317        int shortNamesOverSize = 0;
 
  320        if(!shortNames.empty()) {
 
  321            shortNames = 
"  " + shortNames;  
 
  322            if(longNames.empty() && !opts.empty())
 
  324            if(!longNames.empty())
 
  326            if(
static_cast<int>(shortNames.length()) >= shortNamesColumnWidth) {
 
  328                shortNamesOverSize = 
static_cast<int>(shortNames.length()) - shortNamesColumnWidth;
 
  330            out << std::setw(shortNamesColumnWidth) << std::left << shortNames;
 
  332            out << std::setw(shortNamesColumnWidth) << std::left << 
"";
 
  337            (std::min)(shortNamesOverSize, longNamesColumnWidth);  
 
  338        const auto adjustedLongNamesColumnWidth = longNamesColumnWidth - shortNamesOverSize;
 
  341        if(!longNames.empty()) {
 
  344            if(
static_cast<int>(longNames.length()) >= adjustedLongNamesColumnWidth)
 
  347            out << std::setw(adjustedLongNamesColumnWidth) << std::left << longNames;
 
  349            out << std::setw(adjustedLongNamesColumnWidth) << std::left << 
"";
 
  353            bool skipFirstLinePrefix = 
true;
 
  356                skipFirstLinePrefix = 
false;
 
  358            detail::streamOutAsParagraph(
 
 
  375    std::stringstream out;
 
  377    if(!opt->get_option_text().empty()) {
 
  378        out << 
" " << opt->get_option_text();
 
  398                out << 
" " << op->get_name();
 
  401            out << 
" " << 
get_label(
"Excludes") << 
":";
 
  403                out << 
" " << op->get_name();
 
 
  413    std::stringstream out;
 
  420    return opt->
get_required() ? out.str() : 
"[" + out.str() + 
"]";
 
 
Creates a command line program, with very few defaults.
Definition App.hpp:98
CLI11_NODISCARD std::string get_usage() const
Generate and return the usage.
Definition App.hpp:1143
CLI11_NODISCARD std::size_t get_require_subcommand_max() const
Get the required max subcommand value.
Definition App.hpp:1156
Option * get_help_ptr()
Get a pointer to the help flag.
Definition App.hpp:1202
CLI11_NODISCARD std::string get_footer() const
Generate and return the footer.
Definition App.hpp:1148
CLI11_NODISCARD const Option * get_help_all_ptr() const
Get a pointer to the help all flag. (const)
Definition App.hpp:1208
App * get_parent()
Get the parent of this subcommand (or nullptr if main app)
Definition App.hpp:1223
CLI11_NODISCARD std::string get_display_name(bool with_aliases=false) const
Get a display name for an app.
Definition App_inl.hpp:910
CLI11_NODISCARD std::size_t get_require_option_max() const
Get the required max option value.
Definition App.hpp:1162
CLI11_NODISCARD bool get_required() const
Get the status of required.
Definition App.hpp:1171
CLI11_NODISCARD std::vector< std::string > get_groups() const
Get the groups available directly from this option (in order)
Definition App_inl.hpp:969
CLI11_NODISCARD const std::vector< std::string > & get_aliases() const
Get the aliases of the current app.
Definition App.hpp:1232
CLI11_NODISCARD std::size_t get_require_option_min() const
Get the required min option value.
Definition App.hpp:1159
CLI11_NODISCARD const std::string & get_group() const
Get the group of this subcommand.
Definition App.hpp:1140
CLI11_NODISCARD std::vector< App * > get_subcommands() const
Definition App.hpp:940
std::vector< const Option * > get_options(const std::function< bool(const Option *)> filter={}) const
Get the list of options (user facing function, so returns raw pointers), has optional filter function...
Definition App_inl.hpp:832
CLI11_NODISCARD std::string get_description() const
Get the app or subcommand description.
Definition App.hpp:1074
CLI11_NODISCARD std::size_t get_require_subcommand_min() const
Get the required min subcommand value.
Definition App.hpp:1153
CLI11_NODISCARD const std::string & get_name() const
Get the name of the current app.
Definition App.hpp:1229
CLI11_NODISCARD bool get_required() const
True if this is a required option.
Definition Option.hpp:137
CLI11_NODISCARD const std::string & get_group() const
Get the group of this option.
Definition Option.hpp:134
Definition Option.hpp:259
CLI11_NODISCARD bool get_positional() const
True if the argument can be given directly.
Definition Option.hpp:628
CLI11_NODISCARD std::string get_envname() const
The environment variable associated to this value.
Definition Option.hpp:573
CLI11_NODISCARD std::string get_type_name() const
Get the full typename for this option.
Definition Option_inl.hpp:537
CLI11_NODISCARD std::string get_name(bool positional=false, bool all_options=false) const
Gets a comma separated list of names. Will include / prefer the positional name if positional is true...
Definition Option_inl.hpp:257
CLI11_NODISCARD std::string get_default_str() const
The default value (for help printing)
Definition Option.hpp:582
CLI11_NODISCARD bool nonpositional() const
True if option has at least one non-positional name.
Definition Option.hpp:631
CLI11_NODISCARD std::set< Option * > get_excludes() const
The set of options excluded.
Definition Option.hpp:579
CLI11_NODISCARD std::set< Option * > get_needs() const
The set of options needed.
Definition Option.hpp:576
CLI11_NODISCARD const std::string & get_description() const
Get the description.
Definition Option.hpp:637
CLI11_NODISCARD int get_expected() const
The number of times the option expects to be included.
Definition Option.hpp:609
CLI11_NODISCARD int get_expected_min() const
The number of times the option expects to be included.
Definition Option.hpp:612
CLI11_NODISCARD int get_expected_max() const
The max number of times the option expects to be included.
Definition Option.hpp:614
CLI11_NODISCARD int get_type_size() const
The number of arguments the option expects.
Definition Option.hpp:562